Dynamic Water Physics 2
Search Results for

    Show / Hide Table of Contents

    Submarine

    Submarine inspector.

    A script that can be attached to AdvancedShipController to control submarine-specific functions. Works with VariableCenterOfMass to adjust buoyancy for depth changes.

    Note: VariableCenterOfMass is part of NWH Common. For detailed information, see NWH Common - Variable Center of Mass.

    Fields
    • ballastChangeSpeed - speed of change of the ballast mass, as a percentage of maxBallastMass. Controls how fast the submarine can take on or release ballast water.
    • 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.
    • keepHorizontal - if enabled submarine will try to keep horizontal by shifting the center of mass.
    • keepHorizontalSensitivity - sensitivity of calculation trying to keep the submarine horizontal. Higher number will mean faster reaction.
    • maxMassOffset - maximum rigidbody center of mass offset that can be used to keep the submarine level.
    • DepthInput - input property for depth control from -1 (surface) to 1 (dive). Positive values add ballast mass to sink, negative values reduce it to surface.
    Setup
    1. Add a Submarine component to the same GameObject that has AdvancedShipController.
    2. Configure the ballast settings: set maxBallastMass to an appropriate value for your submarine and adjust ballastChangeSpeed to control how quickly the submarine changes depth.
    3. Enable keepHorizontal if you want the submarine to automatically maintain a level orientation. Adjust keepHorizontalSensitivity and maxMassOffset to fine-tune the leveling behavior.
    4. Ensure the vessel has a VariableCenterOfMass component. For more information, see NWH Common - Variable Center of Mass.
    5. Set up depth input controls through your input system. The DepthInput property accepts values from -1 (surface) to 1 (dive).
    • Edit this page
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics