Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

PhysicsBody.ApplyBuoyancy

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void ApplyBuoyancy(BuoyancyInput input, float deltaTime);

Parameters

Parameter Description
input The fluid and force configuration. See BuoyancyInput.
deltaTime The simulation step duration in seconds. Used to clamp damping so it cannot overshoot in a single step.

Description

Apply buoyancy, flow and damping forces to the body based on how its attached shapes are submerged in a fluid plane. Forces and torques are continuous (not impulses), so this is expected to be called every simulation step. The body must be PhysicsBody.BodyType.Dynamic; otherwise a warning is logged and the call is a no-op.


Declaration

public static void ApplyBuoyancy(BuoyancyInput input, ReadOnlySpan<PhysicsBody> bodies, float deltaTime);

Parameters

Parameter Description
input The fluid and force configuration. See BuoyancyInput.
bodies The bodies that buoyancy should be applied to.
deltaTime The simulation step duration in seconds. Used to clamp damping so it cannot overshoot in a single step.

Description

Apply buoyancy, flow and damping forces to every body in based on how their attached shapes are submerged in a fluid plane. The same BuoyancyInput is applied to all bodies. Each body must be PhysicsBody.BodyType.Dynamic; non-dynamic or invalid bodies log a warning and are skipped. Forces and torques are continuous (not impulses), so this is expected to be called every simulation step.


Declaration

public static void ApplyBuoyancy(PhysicsWorld world, PhysicsAABB aabb, BuoyancyInput input, float deltaTime);

Parameters

Parameter Description
world The world to query for overlapping shapes.
aabb The world-space axis-aligned box describing the fluid volume. Only shapes whose broadphase AABB overlaps this box are processed.
input The fluid and force configuration. See BuoyancyInput.
deltaTime The simulation step duration in seconds. Used to clamp damping so it cannot overshoot in a single step.

Description

Apply buoyancy, flow and damping forces to every dynamic body shape that overlaps in . The same BuoyancyInput is applied to all overlapping shapes. Shapes whose body is not PhysicsBody.BodyType.Dynamic are silently skipped. Forces and torques are continuous (not impulses), so this is expected to be called every simulation step.