Class Sink
Simulates a ship taking on water and sinking by gradually increasing mass over time. Works with VariableCenterOfMass component to affect buoyancy and cause the ship to sink. Can be triggered to simulate hull breaches or flooding.
Implements
Namespace: NWH.DWP2.ShipController
Assembly: NWH.DWP2.dll
Syntax
public class Sink : MonoBehaviour, IMassAffector
Fields
| Edit this page View SourceaddedMassPercentPerSecond
Rate at which mass is added per second as a percentage of maxAdditionalMass. Higher values cause faster sinking.
Declaration
[Tooltip("Percentage of initial mass that will be added each second to imitate water ingress")]
public float addedMassPercentPerSecond
Field Value
| Type | Description |
|---|---|
| float |
maxAdditionalMass
Maximum mass in kg that can be added through flooding. This represents the total water mass that can enter the ship.
Declaration
[Tooltip("Maximum added mass after water ingress. 1f = 100% of orginal mass, 2f = 200% of original mass, etc.")]
public float maxAdditionalMass
Field Value
| Type | Description |
|---|---|
| float |
Methods
| Edit this page View SourceGetMass()
Current mass of this affector in kilograms. Should return variable values for fuel tanks, cargo, etc.
Declaration
public float GetMass()
Returns
| Type | Description |
|---|---|
| float | Mass in kg |
GetTransform()
Returns transform of the mass affector.
Declaration
public Transform GetTransform()
Returns
| Type | Description |
|---|---|
| Transform |
GetWorldCenterOfMass()
World position of this affector's center of mass. Used for weighted center of mass calculations.
Declaration
public Vector3 GetWorldCenterOfMass()
Returns
| Type | Description |
|---|---|
| Vector3 |
ResetMass()
Resets the added mass to zero, returning the ship to its original mass.
Declaration
public void ResetMass()
SinkCoroutine()
Coroutine that gradually increases mass to simulate water ingress.
Declaration
public IEnumerator SinkCoroutine()
Returns
| Type | Description |
|---|---|
| IEnumerator |
StartSinking()
Begins the sinking process by starting mass increase over time.
Declaration
public void StartSinking()
StopSinking()
Stops the sinking process. Added mass remains until reset.
Declaration
public void StopSinking()