Physics · function

applyBuoyancy

Apply it, and report whether the body is submerged.

Explained in Your first game, Rigid bodies.

function applyBuoyancy(water: Buoyancy, y: number, state: BuoyantState, dt: number): boolean
import { applyBuoyancy } from '@driftengine/physics';

Parameters

ParameterTypeDescription
waterBuoyancy
ynumberWhere the body is. Under level is submerged.
stateBuoyantState
dtnumber

Returns Whether it was, so a consumer can count the time or drown somebody — which is a game's decision and not this function's.