Floaters

Points that simulate buoyancy on an object.

How Floaters Work

Floaters are points that keep track of all FloatVolumes, FlowForces, and GravityZones that they enter and exit, applying the appropriate forces to their attached rigidbody to simulate buoyancy. Their physics are applied every FixedUpdate.

Floaters that are "Underwater" will continuously apply force to itself in the direction of the water's surface. The closer to the surface a Floater is, the less force is applied upwards. Eventually balancing out with gravity near the water's surface.

You can have as many Floater Points on an object as you want, but every Floater Point has a performance cost. To save on performance, all physics calculations for floaters are only performed by the owner of the object.

See Custom Floater Setup for instructions on creating floaters.

Rotation Stabilization

You can enable Stabilize Rotation on a floater to assist floaters in remaining upright while in the water. The rotation stabilization forces are only active while the floater is in the water. This stabilization works best with only one or two floater points.

Gravity Zones

You can provide a Default Gravity Zone to floaters if you want them to not be affected by normal gravity. For example, you could have a water planet that you want all your floaters to gravitate towards instead of falling into the void.

Advanced

Starting floaters inside FloatVolumes or FlowForces

In the "Debug" section of the Floater, you can assign initial Influencing Float Volumes and Influencing Flow Forces. Make sure you increment the Influencing Volume Count/Influencing Flow Force Count accordingly.

This needs to be done with all floater points that start within those triggers.

Public Functions

There are public functions provided so you can write scripts that alter floater behavior on demand.

  • IsUnderwater -> Returns if the floater is in the water or not. Floaters typically rest slightly under the water surface. Can be used to determine if the floater is in the water or not.

  • AddWaterVolume -> Adds the specified water volume to the influencing volumes list.

  • RemoveWaterVolume -> Removes the specified water volume from the influencing volumes list.

  • AddFlowForce -> Adds the specified Flow Force to the influencing forces list.

  • SetAdditionalFlowForce -> Set an arbitrary force on the floater. Will replace the previous additional force.

  • ClearAdditionalFlowForce -> Removes the additional force.

  • RemoveFlowForce -> Removes the specified Flow Force from the influencing forces list.

  • EnterGravityZone -> Sets the current Gravity Zone to the provided zone

  • ExitGravityZone -> Removes the Gravity Zone from the gravity zone list

  • GetGravityNormal -> Returns the normalized direction of the gravity affecting the floater.

  • GetGravityZone -> Returns the current Gravity Zone

  • ClearAllGravityZones -> Removes all Gravity Zones from the stack.

Last updated