PhysicsBody.BuoyancyInput
Input to PhysicsBody.ApplyBuoyancy describing the fluid surface, density, flow and damping used to compute buoyancy, flow and damping forces for the body.
Read time 2 minutesLast updated 12 days ago
Definition
- Type: Struct
- Namespace: Unity.U2D.Physics
- Assembly: UnityEngine.PhysicsCore2DModule
- Implements: IEquatable<BuoyancyInput>
public struct PhysicsBody.BuoyancyInput : IEquatable<PhysicsBody.BuoyancyInput>
Constructors
Constructor | Description |
|---|---|
| BuoyancyInput() | Create a default PhysicsBody.BuoyancyInput. The _mask defaults to PhysicsMask.All so every attached shape contributes unless explicitly filtered out. The surface defaults to a flat horizontal water surface at the world origin (_surfacePosition = _zero, _surfaceNormal = _up). |
Properties
Property | Description |
|---|---|
| angularDamping | Angular damping coefficient. Slows the body's angular velocity while submerged. |
| density | The fluid density, used to compute the Archimedean buoyancy force per submerged unit area. Clamped to a lower bound of Mathf.Epsilon. |
| flowDirection | The direction of the fluid flow as a 2D rotation. Combined with _flowSpeed to produce the flow velocity vector applied as force per unit submerged area at the submerged centroid. |
| flowSpeed | The magnitude of the fluid flow along _flowDirection. The per-shape force contribution is flowDirection " flowSpeed " submergedArea. |
| linearDamping | Linear damping coefficient. Slows the body's linear velocity at the submerged centroid relative to the fluid. |
| mask | Category mask used to filter which attached shapes contribute. A shape participates iff (shape.contactFilter.categories.bitMask & mask.bitMask) != 0. Defaults to PhysicsMask.All when the input is created via the parameterless constructor. |
| surfaceNormal | The outward-pointing surface normal of the fluid, in world space. Points away from the submerged side; shape points with a negative separation from the plane are submerged. Defaults to _up (a flat horizontal water surface). Must be non-zero; the engine normalises it internally so it does not need to be unit length. |
| surfacePosition | A point in world space lying on the fluid surface. Together with _surfaceNormal this defines the infinite plane of the fluid. |
| useTriggers | When true, trigger shapes contribute to buoyancy alongside non-trigger shapes. When false, trigger shapes are skipped. |