Buoyancy

How it works

The buoyancy system is based on a conventional method of repeating wave calculations performed on the GPU on the CPU. The key distinction lies in the fact that while GPU computes waves for each vertex of the mesh, the buoyancy system computes waves for limited amount of points, attached to a floating object, known as BuoyancyPoints.

PlanetaryBuoyancy component must be attached to an Actor to enable floating. This component computes the depth below (or above) water for a specified array of BuoyancyPoints on the CPU. Using this data, it applies forces to the BuoyancyPoints. It also includes built-in gravity.

PlanetaryOcean blueprint synchronizes wave parameters between the ocean material and the PlanetaryBuoyancy to ensure consistent values for the buoyancy system.

Setting up buoyancy

To set up buoyancy on your Actor, follow these steps:

  • Add PlanetaryBuoyancy component to your Actor blueprint.

  • In the component settings fill the Buoyancy Points array. Vector locations it is asking for are in local space (relative to the root). It is recommended to have more than 4 Buoyancy Points for smoother buoyancy simulation. System will sample the water height and apply buoyancy forces at these locations.

  • Make the Static Mesh Component you want to float as root component. Static Mesh can have any other components attached to it (meshes, cameras, particles etc.)

  • Buoyancy Component will set on the Static Mesh Component Simulate Physics to true and Gravity to false on BeginPlay. You will see the corresponding warnings in the engine output log. If you'd like to prevent these warnings, you can manually set these variables.

  • If your Actor is added to the level, you can navigate to the Primary Ocean category in the component settings and set the existing in the level BP_PlanetaryOcean to the ocean you'd like this Actor to float on. If not set, the Buoyancy Component will assign the first found in the level object of class APlanetaryOcean on BeginPlay and use it.

  • Now you can press Play and tweak the buoyancy settings.

Last updated

Was this helpful?