Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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

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

angularDampingAngular damping coefficient. Slows the body's angular velocity while submerged.
densityThe fluid density, used to compute the Archimedean buoyancy force per submerged unit area. Clamped to a lower bound of Mathf.Epsilon.
flowDirectionThe 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.
flowSpeedThe magnitude of the fluid flow along _flowDirection. The per-shape force contribution is flowDirection " flowSpeed " submergedArea.
linearDampingLinear damping coefficient. Slows the body's linear velocity at the submerged centroid relative to the fluid.
maskCategory 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.
surfaceNormalThe 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.
surfacePositionA point in world space lying on the fluid surface. Together with _surfaceNormal this defines the infinite plane of the fluid.
useTriggersWhen true, trigger shapes contribute to buoyancy alongside non-trigger shapes. When false, trigger shapes are skipped.