Table of Contents

Floating Body

Floating Body is a ready-to-use example implementation of Water Behaviour, that works on top of Unity's RigidBody.


Water Sampler Config

This section comes from base Water Behaviour component and it is used to configure internal Water Sampler.


Geometry Settings

Here you configue actual shape of body that will be used for the buoyancy physics.

It consists of two parts:

Every body is unique and may need different recipe how to configure its floating geometry.
However, here's a few general tips for most body types like ships:

Editing Geometry

To edit geometry, toggle Edit Mode button. You can edit center of mass and contact points in two ways:

Simple Disc Placer

This is primitive tool that may help you initially place contact points for faster prototyping.
It uses a XZ plane disc to raycast N points towards the middle of body at specified height level.
Manipulate with radius, amount of samples and angle offset to quickly place points evenly on hull.
Press Add to add newly scanned points and Clear to clear everything at given height level.
Preview raycast drawn as gizmo will be helpful.
Repeat it few times at different height levels.

This is just prototyping tool. In the end you should do final touches manually to make all contact points with equal and symmetrical offsets.


Force

Here you configure actual buyonace force.
This force is evenly splitted for every contact point and applied on it individually if given point is submerged.

NOTE: Buoyancy force is additionaly multiplier by factor defined by Water Surface that body is floating on.


Submerge Drag

Rigidbody should have more drag in water than in air.
Here you can add extra Drag and Angular Drag to rigidbody when its fully submerged. Applied drag is scaled by submerge level.
Submerge level is a percentage value determined by amount of contact points that are below water.

NOTE: There are also extra drag values added by Water Surface itself, where you can configure it too.
NOTE: Submerge drag values are not actually added to rigidbody drag values, but are calculated independently, so you can still change your rigidbody values runtime as you want without breaking floating body state.