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.
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 SourceballastChangeSpeed
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 |
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 |
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 |
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 |
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 SourceBallastMass
Current ballast mass added to the submarine.
Declaration
public float BallastMass { get; }
Property Value
| Type | Description |
|---|---|
| float |
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 |
TotalMass
Total mass of the submarine (base mass + ballast).
Declaration
public float TotalMass { get; }
Property Value
| Type | Description |
|---|---|
| float |