# ApplyBuoyancy

> 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.

## Definition

* **Type:** Method
* **Namespace:** [Unity.U2D.Physics](/engine/6000.7/script-reference/unity/u2d/physics.md)
* **Assembly:** UnityEngine.PhysicsCore2DModule

## ApplyBuoyancy(BuoyancyInput, float)

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](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/bodytype/dynamic.md); otherwise a warning is logged and the call is a no-op.

```csharp
public void ApplyBuoyancy(PhysicsBody.BuoyancyInput input, float deltaTime)
```

### Parameters

**** (\[BuoyancyInput]\(/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/buoyancyinput)): The fluid and force configuration. See [PhysicsBody.BuoyancyInput](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/buoyancyinput.md).**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The simulation step duration in seconds. Used to clamp damping so it cannot overshoot in a single step.

## ApplyBuoyancy(BuoyancyInput, ReadOnlySpan\<PhysicsBody>, float)

Apply buoyancy, flow and damping forces to every body in `bodies` based on how their attached shapes are submerged in a fluid plane. The same [PhysicsBody.BuoyancyInput](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/buoyancyinput.md) is applied to all bodies. Each body must be [PhysicsBody.BodyType.Dynamic](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/bodytype/dynamic.md); 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.

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

### Parameters

**** (\[BuoyancyInput]\(/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/buoyancyinput)): The fluid and force configuration. See [PhysicsBody.BuoyancyInput](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/buoyancyinput.md).**** (\[ReadOnlySpan\<PhysicsBody>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The bodies that buoyancy should be applied to.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The simulation step duration in seconds. Used to clamp damping so it cannot overshoot in a single step.

## ApplyBuoyancy(PhysicsWorld, PhysicsAABB, BuoyancyInput, float)

Apply buoyancy, flow and damping forces to every dynamic body shape that overlaps `aabb` in `world`. The same [PhysicsBody.BuoyancyInput](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/buoyancyinput.md) is applied to all overlapping shapes. Shapes whose body is not [PhysicsBody.BodyType.Dynamic](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/bodytype/dynamic.md) are silently skipped. Forces and torques are continuous (not impulses), so this is expected to be called every simulation step.

```csharp
public static void ApplyBuoyancy(PhysicsWorld world, PhysicsAABB aabb, PhysicsBody.BuoyancyInput input, float deltaTime)
```

### Parameters

**** (\[PhysicsWorld]\(/engine/6000.7/script-reference/unity/u2d/physics/physicsworld)): The world to query for overlapping shapes.**** (\[PhysicsAABB]\(/engine/6000.7/script-reference/unity/u2d/physics/physicsaabb)): The world-space axis-aligned box describing the fluid volume. Only shapes whose broadphase AABB overlaps this box are processed.**** (\[BuoyancyInput]\(/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/buoyancyinput)): The fluid and force configuration. See [PhysicsBody.BuoyancyInput](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/buoyancyinput.md).**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The simulation step duration in seconds. Used to clamp damping so it cannot overshoot in a single step.
