Dynamic Water Physics 2
Search Results for

    Show / Hide Table of Contents

    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.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    Sink
    Implements
    IMassAffector
    Namespace: NWH.DWP2.ShipController
    Assembly: NWH.DWP2.dll
    Syntax
    public class Sink : MonoBehaviour, IMassAffector

    Fields

    | Edit this page View Source

    addedMassPercentPerSecond

    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
    | Edit this page View Source

    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 Source

    GetMass()

    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

    | Edit this page View Source

    GetTransform()

    Returns transform of the mass affector.

    Declaration
    public Transform GetTransform()
    Returns
    Type Description
    Transform
    | Edit this page View Source

    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
    | Edit this page View Source

    ResetMass()

    Resets the added mass to zero, returning the ship to its original mass.

    Declaration
    public void ResetMass()
    | Edit this page View Source

    SinkCoroutine()

    Coroutine that gradually increases mass to simulate water ingress.

    Declaration
    public IEnumerator SinkCoroutine()
    Returns
    Type Description
    IEnumerator
    | Edit this page View Source

    StartSinking()

    Begins the sinking process by starting mass increase over time.

    Declaration
    public void StartSinking()
    | Edit this page View Source

    StopSinking()

    Stops the sinking process. Added mass remains until reset.

    Declaration
    public void StopSinking()

    Implements

    IMassAffector
    • Edit this page
    • View Source
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics