> For the complete documentation index, see [llms.txt](https://docs.shadersource.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shadersource.io/assets-and-plugins/ocean-tool-2/tutorials/buoyancy-and-boats.md). Agents can also search and read this documentation through its [MCP server](https://docs.shadersource.io/~gitbook/mcp).

# Buoyancy and Boats

Float your own meshes on the ocean, make a boat you can drive, and give both a wake.

Anything can float on an Ocean Tool 2 ocean, and it floats on the waves you see: the ocean keeps an exact copy of its drawn waves for physics. In this tutorial you float a mesh of your own, turn another into a boat you can drive, and switch on their wakes.

![Floating objects in the Buoyancy example map - a buoy, seaweed, barrels and logs - with a boat sailing past](https://2855220899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk51ACJUA5E3mZvLb9h%2Fuploads%2FO6w4EwHAD43G45rx0ZHu%2Fbuoy_hero.webp?alt=media)

|                  |                                                                                                                                                                                                |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Time**         | About 15 minutes                                                                                                                                                                               |
| **You need**     | A level with an ocean ([Ocean and Shoreline](https://docs.shadersource.io/assets-and-plugins/ocean-tool-2/tutorials/ocean-and-shoreline.md), Part 1), and one or two static meshes of your own |
| **You will use** | **Simple > Buoyancy & Wakes**                                                                                                                                                                  |

{% hint style="info" %}
**See it all first.** Open `L_OceanTool2_Buoyancy` from the plugin's `Examples/Buoyancy/Maps` folder and press Play: every kind of floating object and both kinds of boat, side by side and labelled.
{% endhint %}

## The two actors

| Actor                       | What it is                                                                                                                   |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| **Ocean 2 Floating Object** | Anything that floats and is not driven: a buoy, a barrel, a log, weed, rubbish.                                              |
| **Ocean 2 Vessel**          | A boat: a floating hull with an engine, a helm, a chase camera and a wake. A player drives it, or it sails a path by itself. |

You need not place either by hand: the **Buoyancy & Wakes** page makes them from your mesh.

## Part 1 - Float a mesh

{% stepper %}
{% step %}

### Open the Buoyancy & Wakes page

In the Ocean Tool 2 mode, open the **Simple** tab and the **Buoyancy & Wakes** page. Scroll to **Boats and Floating Objects**.

![Buoyancy & Wakes: wakes on top, the mesh picker and the two Make buttons at the bottom](https://2855220899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk51ACJUA5E3mZvLb9h%2Fuploads%2FuJQobfkrqvNSMSZKL02o%2Fbuoy_page.png?alt=media)
{% endstep %}

{% step %}

### Pick your mesh

Click the mesh picker and choose your static mesh - a crate, a barrel, a log. Any pivot will do.
{% endstep %}

{% step %}

### Press Make a floating object

A Blueprint named `BP_<your mesh>_Floating` is made next to the mesh, fitted to it, and one is placed on the water in front of the camera, selected.

{% hint style="warning" %}
**Press File > Save All** (**Ctrl + Shift + S**). The new Blueprint is not saved yet, and neither is the one placed in the level. If you save only the level, the Blueprint is lost when the editor closes and the placed object with it.
{% endhint %}
{% endstep %}

{% step %}

### Press Play

It floats: bobbing, rolling and drifting with the water. Press **Simulate** instead of Play to watch it from the editor's camera.
{% endstep %}

{% step %}

### Choose how it floats

Select the placed object and find **Floating Mode** in its Details panel (or open the Blueprint and change it on **Class Defaults**, so every copy follows).

|                        | **Simple (follows the waves)**                                | **Physics**                                                                       |
| ---------------------- | ------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| How it moves           | Bobs, pitches and rolls on the water under it                 | A rigid body the water pushes about: it tumbles, collides and can be knocked over |
| Cost                   | Very cheap - use it for crowds                                | A physics body each                                                               |
| Collides               | Never pushed; boats and physics objects bump into it          | With everything                                                                   |
| In the editor viewport | Floats there too                                              | Floats there with **Physics floating in the editor** on                           |
| Good for               | Buoys, weed, distant debris, anything that should stay steady | Barrels, logs, crates, rubbish in the surf                                        |

![Floating objects in the Buoyancy example map: a buoy and seaweed on Simple, barrels and logs on Physics](https://2855220899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk51ACJUA5E3mZvLb9h%2Fuploads%2FOgFC3Ef1y5lKV8NcnQyY%2Fbuoy_modes.jpg?alt=media)
{% endstep %}

{% step %}

### Make it sit right in the water

Three rows decide how high it rides:

* **Density** - kilograms a cubic metre. Water is 1000, wood about 500, a hollow plastic float about 150. Lighter floats higher.
* **Fill** - how much of its bounding box the mesh really fills: a barrel about 0.7, a log 0.75, weed 0.3.
* **Stay Upright** - weighted low, as a buoy is. It floats upright and rights itself when the waves tip it.
  {% endstep %}

{% step %}

### Let it drift, or moor it

* **Drift** (on by default) lets the water carry it: to and fro with the swell, in with the surf, up the sand and back with the wash.
* **Moored** holds it within **Mooring Length** of where it starts, as by a line to an anchor.
  {% endstep %}
  {% endstepper %}

{% hint style="success" %}
**Ready-made ones.** `Examples/Floating` has a Blueprint for each kind to place or copy: a buoy, a barrel, a log, seaweed, and eight pieces of rubbish.
{% endhint %}

## Part 2 - Make a boat

{% stepper %}
{% step %}

### Prepare the hull mesh

Three things make a hull measure and float properly:

* **X points to the bow**, Z is up, and it is at its real size (one unit is a centimetre).
* **The pivot is on the waterline.** A pivot at the keel works too - you then tell the boat how far up the waterline is (**Hull Waterline Height**).
* **It has simple collision** that follows the hull - a few convex hulls or a box. The cabin and mast need none.
  {% endstep %}

{% step %}

### Pick it and press Make a boat

On the **Buoyancy & Wakes** page, pick the hull mesh and press **Make a boat**.

A Blueprint named `BP_<your mesh>_Boat` is made next to the mesh and one is placed on the water. It has measured itself from the mesh: its waterline length, beam, draft and displacement.

As with a floating object, press **File > Save All** to keep the new Blueprint as well as the placed boat.
{% endstep %}

{% step %}

### Choose how it handles

Open the Blueprint and look at **Class Defaults**. Under **Handling**, choose a **Handling Preset** and press **Apply Handling Preset**.

| Preset       | The vessel                                                         | Its controls                                        |
| ------------ | ------------------------------------------------------------------ | --------------------------------------------------- |
| **PWC**      | A three-metre water jet: fast, planing, leaning into its turns     | A sprung throttle; little steering off the throttle |
| **Workboat** | A twenty-metre workboat with a propeller and a rudder              | A throttle lever that stays where it is put         |
| **Warship**  | A very large, fast ship with a long stop and a wide turning circle | A ship's telegraph and a slow steering engine       |

Scale the actor and the boat follows: its size with the scale, its mass with the scale cubed.
{% endstep %}

{% step %}

### Check that it floats level

Press **Simulate**. If the boat sits wrong:

| It...                                        | Change                                                                                                          |
| -------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| Sits too low or too high                     | **Displacement** - its mass. A heavy workboat displaces more than its size suggests, a light planing hull less. |
| Floats with its waterline in the wrong place | **Hull Waterline Height** - how far above the mesh's pivot the waterline is.                                    |
| Rolls over                                   | Lower **Centre Of Mass Height**. Check the collision is the hull, not a box round the whole superstructure.     |
| {% endstep %}                                |                                                                                                                 |

{% step %}

### Drive it

Select the placed boat, set **Auto Possess Player** to **Player 0** and press Play.

| Control                       | Keyboard and mouse | Gamepad          |
| ----------------------------- | ------------------ | ---------------- |
| Throttle                      | **W** / **S**      | Triggers         |
| Steer                         | **A** / **D**      | Left stick       |
| Stop the engine               | **X**              | Left face button |
| Right the boat if it capsizes | **R**              | Top face button  |
| Look around, zoom             | Mouse, wheel       | Right stick      |

To drive it from your own input or AI instead, turn **Default Controls** off and call **Set Controls** (throttle and steering, each -1 to 1).
{% endstep %}

{% step %}

### Or let it sail by itself

Place an **Ocean 2 Boat Path** in the level and shape it like any spline. Set it as the boat's **Autopilot Path**.

With no player at the helm, the boat sails the path with its own engine and rudder. Take the helm and you drive it; let go and the autopilot picks the path up again.
{% endstep %}
{% endstepper %}

![The example workboat sailing its path in the Buoyancy map, its wake behind it](https://2855220899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk51ACJUA5E3mZvLb9h%2Fuploads%2FFyQFBJ6MovYLL6Yb7Bvd%2Fbuoy_boat.webp?alt=media)

## Part 3 - Wakes

Boats and floating objects push the water, but only when wakes are on. A new ocean has them off, because they cost GPU time while they run.

{% stepper %}
{% step %}

### Turn on Wakes

At the top of the **Buoyancy & Wakes** page, tick **Wakes**. Boats now leave a real wake - bow wave, stern wave and the V behind - and floating objects ripple the water as they bob.
{% endstep %}

{% step %}

### Decide what the wake area follows

Wakes are simulated in an area of water, not across the whole sea. **Wake area follows** says where that area is:

* **View** (the default) - round the camera. A boat outside it makes no wake until it comes into view.
* **Wake sources** - the area follows the boats with the highest priority, whatever the camera does. A boat a player is driving takes it.

**Wake area** sets its size. Larger reaches further, with coarser ripples.
{% endstep %}

{% step %}

### Let things ride the wakes

Tick **Floating things ride wakes** and boats and floating objects rise and fall on each other's wakes as well as on the waves.

**Fine wake round the view** (on with the wakes) runs a second, much finer wake close to the camera, so small things - a swimmer, a bottle, a splash - make ripples of their own size.
{% endstep %}
{% endstepper %}

![A boat's wake in the Buoyancy example map](https://2855220899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk51ACJUA5E3mZvLb9h%2Fuploads%2FxDowfiVOjJGTeAz4rNlT%2Fbuoy_wake.jpg?alt=media)

## Contact foam

Where a floating object meets the water, a line of foam follows its waterline in the object's own shape. It is on by default (**Contact foam** on the page; **Contact Foam** on each object).

It reads the engine's custom depth pass (**Project Settings > Rendering > Custom Depth-Stencil Pass**), which is enabled in a new project.

## Floating in the editor

Simple floating objects float in the editor viewport as they are. Physics ones and boats float only in play - unless you tick **Physics floating in the editor**. Each goes back to where you placed it when you turn the option off, save the level or press Play.

## Something not right?

| What you see                                  | What to check                                                                                                                            |
| --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| It sinks, or floats too high                  | **Density** for a floating object, **Displacement** for a boat.                                                                          |
| A buoy falls over                             | Turn on **Stay Upright**.                                                                                                                |
| A boat rolls over                             | Lower **Centre Of Mass Height**; check its collision is the hull.                                                                        |
| No wake or ripples                            | **Wakes** is on. The wake area follows the camera by default: a boat outside it makes none.                                              |
| It ignores the shore's waves                  | Its **Drift** is on and the ocean's **Waves carry floating things** is on. On the Simulated shore, **Float on the simulated shore** too. |
| Hundreds of objects are slow                  | Use **Simple**, and turn **Make Ripples** off on each.                                                                                   |
| A character climbs onto small floating things | Raise their **Stand On Mass**.                                                                                                           |

## Going further

* [Boats, Buoyancy and Wakes](https://docs.shadersource.io/assets-and-plugins/ocean-tool-2/how-to-use/boats-buoyancy-and-wakes.md) - the full reference: every setting of the vessel and the floating object.
* [Make a Boat From Your Mesh](https://docs.shadersource.io/assets-and-plugins/ocean-tool-2/how-to-use/boats-buoyancy-and-wakes/make-a-boat-from-your-mesh.md) - hull measurements, handling and the wake's look in detail.
* [Buoyancy and Wake Components](https://docs.shadersource.io/assets-and-plugins/ocean-tool-2/how-to-use/boats-buoyancy-and-wakes/buoyancy-and-wake-components.md) - float and wake actors of your own.
* [Water in Blueprints](https://docs.shadersource.io/assets-and-plugins/ocean-tool-2/tutorials/water-in-blueprints.md) - read the water's height yourself.
