Floating Objects#

Crest is capable of supporting various floating objects from barrels to watercraft.

Physics#

Floating Object handles all physics interactions including buoyancy and drag. It has two models available: Align Normal and Probes.

Align Normal is a simple buoyancy model that attempts to match the object position and rotation with the surface height and normal. This can work well enough for small watercraft that do not need perfect floating behaviour, or floating objects such as buoys, barrels, etc. Furthermore, this model is less affected by physics, like mass, making authoring much easier like adding additional colliders.

Probes is a more advanced implementation that computes buoyancy forces at a number of Probes and uses these to apply force and torque to the object. This gives more accurate results at the cost of more queries.

Usage#

Steps to get started:

  1. Add a Floating Object to your Rigidbody.

  2. Choose a model on the Floating Object.

    1. Add probes if using the Probes model.

  3. Configure the Floating Object.

    • Force Strength is the most important value for keeping the object afloat. This value will differ greatly depending on the chosen model. Probes will take the rigid body mass into account. Align Normal will not and requires balancing Force Strength with Height Offset to get desired results.

    • Drag and Object Width/Length are important for keeping the object stable.

Troubleshooting#

If a floating object is behaviing eratically, then there could be an internal collision. Review your collider hierarchy and see if it can be simplified.

Movement#

Several scripts exist for adding movement to floating objects to make watercraft.

Usage#

  • Add a Controller to a Floating Object

  • Add a control to the Controller

Controller#

Controller is a general purpose watercraft controller script. It can control thrust, steer and dive mechanics by adding forces to the rigid body directly.

Controls#

A control is an abstraction to allow input from various sources. It simply provides an XYZ value which maps to steer, dive and thrust respectively. We provide a few controls in the package.

Example

For a player control example, import the Boats sample. The Player Control works with both old and new Unity input systems. There is also a dive capable control in the Submarine sample. These are only examples because they are not the ideal usage of Unity’s input systems.

The idea is that developers can easily make their own controls by extending the Control class. Input could come from the Unity input system or from some mechanic in the game world like a lever.

Fixed Control#

Simply provdes a constant input which is configurable from the editor.

Interactions#

The Sphere Water Interaction component is used to add interactions to floating objects like wakes. See Adding Interaction Forces section for more information on this component.

Watertightness#

There are various methods to removing water from Crest detailed on the Water Exclusion page.