Table of Contents

Advanced Ship Controller

Quick Start

For the example setup a primitive capsule will be used (GameObject menu > 3D Object > Capsule).

Capsule representing a ship.
  1. Add the ship object into the scene and tag it Ship (add a new tag if it does not exist). The tag is only necessary so that the ship changer can find your ship.
  2. Add WaterObjectWizard component to the ship object.
  3. Add AdvancedShipController component to the parent object (the one containing the Rigidbody).
  4. Add CenterOfMass component to the parent object and adjust center of mass to be near the bottom of the ship (green sphere). If this is not done the ship will most likely tilt to the side since the center of mass in Unity is calculated as a center of volume of all of the Rigidbody colliders, which is unrealistic for ships which generally have the center of mass near the keel.
  5. Make sure that the input has been set up as per Input guide above.

Rudders

As an example a simple primitive cube will be used.



  1. Add a rudder (in this case just a scaled cube) to the ship.
  2. Assign the rudder transform (in this example the scaled cube) to the Rudder Transfrom field under Rudders foldout.
  3. Add WaterObject component to the rudder so it too can interact with water.
  4. Add a Camera of any type to the ship object (as a child) and tag it ShipCamera.
  5. Press play and cycle to your ship using the V button (default change ship button). The boat is now floating and the rudders turn. If the rudders turn around wrong axis the rotation of the model needs to be fixed. Check this link for a guide on how to fix the model rotation.

Engines

Engine section of AdvancedShipController.
  1. To make ship move an engine and propeller are needed. Ship Controller assumes that there is one propeller per engine. Add an engine under Engines tab and set the wanted values (hover over each value to see what it does). If thrust position is above the water thrust will not be applied (if Apply Thrust When Above Water is left unchecked).
  2. Default thrust position is at [0,0,0]. Make sure to adjust this value to fit your ship.
An example engine setup with thrust point shown as red sphere and thrust direction as a red line.

Thrusters

An example thruster with thrust point showin as a sphere and thrust direction as a blue line.

Larger ships usually have bow and/or stern thrusters to help them maneuver. Thruster is indicated as a blue sphere with a a line indicating direction of thrust when positive input is pressed.

Sound

Sound section of AdvancedShipController

Engine sound is achieved through simple pitch modulation. To set up sound:

Field Explanations

Engine

Engine inspector.

Engine represent a single inboard or outboard engine. It handles power delivery, propeller rotation and engine sound.
Each ship can have multiple engines.

By default the thrust position of the engine is at [0,0,0]. Be sure to adjust this value to fit your ship.

Fields
  • IsOn - is the engine currently on.
  • MinRPM, MaxRPM - minimum and maximum RPM the engine can achieve. Stalling is not supported.
  • Max Thrust - maximum thrust that the engine can generate at MaxRPM.
  • Spin Up Time - time needed for the engine to reach MaxRPM.
  • Starting RPM - RPM at which the engine will run while starting.
  • Start Duration, Stop Duration - duration of engine starting and stopping. Influences for how long the start sound will be played.
  • Thrust Position - position at which the thrust force will be applied. Local coordinates.
  • Thrust Direction - direction in which the thrust will be applied. Local coordinates.
  • Apply Thrust When Above Water - set to true if you want the propeller to work even when out of water. False by default.
  • Reverse Thrust Coefficient - thrust coefficient when throttle is negative.
  • Max Speed - maximum speed a propeller can achieve.
  • Thrust Curve - thrust percentage (of Max Thrust is represented on the Y axis) and speed is represented on the X axis as a percentage (0,1) of Max Speed). This is essentially a speed/efficiency curve of a propeller.
  • Rudder Transform - a transform representing the rudder. Can be used when the engine is outboard and the thrust should be applied in the direction of the rudder.
  • Propeller Transform - a transform which will represent the propeller. Visual only, does not interact with water.
  • Propeller Rpm Ratio - ratio between engine RPM and propeller RPM.
Setup
  1. To make ship move an engine and propeller are needed. Ship Controller assumes that there is one propeller per engine. Add an engine under Engines tab and set the wanted values (hover over each value to see what it does). If thrust position is above the water thrust will not be applied (if Apply Thrust When Above Water is left unchecked).
2023/05/14 16:42

Rudder

Rudder inspector.

Rudder is used for steering the ship.

  • Each rudder is a WaterObject and controls the ship through regular interaction with water.
  • Invisible rudder can be used in case the visual one is too small. To achieve this parent a very thin Cube to the rudder, use WaterObjectWizard to set it up, resize it to the desirable scale and finally disable MeshFilter. This will result in a rudder that interacts with water but is not visible.
Fields
  • RudderTransform - the transform that will be rotated.
  • MaxAngle - maximum angle of rudder rotation to each side (e.g. +/- 30).
  • RotationSpeed - rotation speed in deg/s for the rudder.
  • LocalRotationAxis - the local axis around which the RudderTransform will be rotated.
Setup
  1. Add a rudder to the ship if it does not already have one. This can be a primitive Cube scaled to a thin shape.
  2. Assign the rudder transform (in this example the scaled cube) to the Rudder Transfrom field.
  3. Add WaterObject component to the rudder so it too can interact with water.
2023/05/14 16:42

Thruster

Thruster inspector.

Thrusters can be used to move a ship without using the main engine(s). They can either apply thrust to the port or starboard side of the ship.

Fields
  • Position - position at which the thrust will be applied.
  • Max Thrust - maximum thrust in [N] which can be applied.
  • Spin Up Speed - reaction time needed to reach Max Thrust
  • Thruster Position - is it a bow or stern thruster. Determines input mapping.
  • Propeller Transform - transform of the propeller that will be used as a visual representation of the thruster. Has to have Unity-correct rotation and pivot.
  • Propeller Rotation Direction - rotation direction of Propeller Transform.
  • Propeller Rotation Speed - rotation speed of the Propeller Transform.
2023/05/14 16:42

Settings

Settings inspector.

These are general ship settings.

Fields
  • Drop Anchor When Inactive - if there is an Anchor component attached to this ship the Anchor will be dropped on sleep.
  • Weigh Anchor When Inactive - if there is an Anchor component attached to this ship the Anchor will be weighed (raised) when ship wakes up.
  • Stabilize Roll - if true a torque will be applied to the ship to try and negate any roll.
  • Roll Stabilization Max Torque - maximum torque that will be used for roll stabilization.
  • Stabilize Pitch - if true a torque will be applied to the ship to try and negate any pitch.
  • Pitch Stabilization Max Torque - maximum torque that will be used for pitch stabilization.
2023/05/14 16:42