codeAPI Reference

s&box WaterVolume: Water buoyancy

calendar_today May 12, 2026 schedule ~1 min read person PatrickJr verified 50

WaterVolume Component API Reference

WaterVolume is a Component that applies buoyancy physics to rigidbodies entering a water volume. Implements ITriggerListener for detection. Automatically added to colliders tagged "water" by GameManager.

Type Signature

CSHARP
public class WaterVolume : Component, Component.ITriggerListener
{
    List<Rigidbody> Bodies = new();
}

Behavior

In OnFixedUpdate:

  • Calculates water surface from BoxCollider (top of the volume)

  • Creates a water plane at the surface

  • Applies buoyancy to all tracked rigidbodies using Rigidbody.ApplyBuoyancy()

ITriggerListener Implementation

GameManager Integration

GameManager.AfterLoad automatically adds WaterVolume to all colliders tagged "water" in the scene.

Usage

CSHARP
// Tag a collider as "water" to enable buoyancy
collider.Tags.Add("water");
// GameManager will automatically add WaterVolume component

Notes

  • Uses BoxCollider to determine water surface (top of volume)
  • Tracks rigidbodies entering/leaving the volume
  • Applies buoyancy each fixed update
  • Automatically added by GameManager on scene load
  • Water surface is calculated as WorldPosition + Up (Scale.z 0.5)
Was this helpful?