Dynamic Water Physics 2
Search Results for

    Show / Hide Table of Contents

    Class Submarine

    Enables submarine functionality by controlling ballast mass for diving and surfacing. Manages depth control through variable mass and can automatically maintain horizontal orientation. Adjusts Rigidbody mass and center of mass directly for depth changes.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    Submarine
    Namespace: NWH.DWP2.ShipController
    Assembly: NWH.DWP2.dll
    Syntax
    [RequireComponent(typeof(AdvancedShipController))]
    [RequireComponent(typeof(Rigidbody))]
    [DefaultExecutionOrder(500)]
    public class Submarine : MonoBehaviour

    Fields

    | Edit this page View Source

    ballastChangeSpeed

    Speed of change of the ballast mass, as a percentage of maxBallastMass.

    Declaration
    [Tooltip("Speed of change of the ballast mass, as a percentage of maxBallastMass.")]
    public float ballastChangeSpeed
    Field Value
    Type Description
    float
    | Edit this page View Source

    keepHorizontal

    If enabled submarine will try to keep horizontal by shifting the center of mass.

    Declaration
    [Tooltip("If enabled submarine will try to keep horizontal by shifting the center of mass.")]
    public bool keepHorizontal
    Field Value
    Type Description
    bool
    | Edit this page View Source

    keepHorizontalSensitivity

    Sensitivity of calculation trying to keep the submarine horizontal. Higher number will mean faster reaction.

    Declaration
    [Tooltip("Sensitivity of calculation trying to keep the submarine horizontal. Higher number will mean faster reaction.")]
    public float keepHorizontalSensitivity
    Field Value
    Type Description
    float
    | Edit this page View Source

    maxBallastMass

    Maximum ballast mass in kg that can be added to make the submarine sink. Higher values allow diving deeper and faster but require more time to surface.

    Declaration
    [FormerlySerializedAs("maxAdditionalMass")]
    [FormerlySerializedAs("maxMassFactor")]
    [Tooltip("Maximum additional mass that can be added (taking on water) to the base mass of the rigidbody to make submarine sink.")]
    public float maxBallastMass
    Field Value
    Type Description
    float
    | Edit this page View Source

    maxMassOffset

    Maximum rigidbody center of mass offset that can be used to keep the submarine level.

    Declaration
    [Tooltip("Maximum rigidbody center of mass offset that can be used to keep the submarine level.")]
    public float maxMassOffset
    Field Value
    Type Description
    float

    Properties

    | Edit this page View Source

    BallastMass

    Current ballast mass added to the submarine.

    Declaration
    public float BallastMass { get; }
    Property Value
    Type Description
    float
    | Edit this page View Source

    DepthInput

    Input for depth control from -1 (surface) to 1 (dive). Positive values add ballast mass to sink, negative values reduce it to surface.

    Declaration
    public float DepthInput { get; set; }
    Property Value
    Type Description
    float
    | Edit this page View Source

    TotalMass

    Total mass of the submarine (base mass + ballast).

    Declaration
    public float TotalMass { get; }
    Property Value
    Type Description
    float
    • Edit this page
    • View Source
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics