# 1 Buoyancy Example

{% hint style="success" %}

#### Like what your seeing?

Support us as a [GitHub Sponsor](https://kb.heathen.group/old-kb/where-to-buy/become-a-sponsor) and get instant access to all our assets, exclusive tools and assets, escalated support and issue tracking and our gratitude.\
\
These articles are made possible by our [GitHub Sponsors](https://kb.heathen.group/old-kb/where-to-buy/become-a-sponsor) ... become a sponsor today!
{% endhint %}

## Introduction

![](https://4053370152-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZWu8yFOWhCYCMkJFmR%2Fuploads%2Fm2CAKCSCmWubS0vlrwPy%2Fimage.png?alt=media\&token=e38b453f-9441-41d8-a63b-41ec0b58e21a)

This scene demonstrates the use of the [Buoyancy Body](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/buoyant-body). [Buoyancy Body Drag](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/buoyant-body-drag) and [Surface Tool](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/surface-tool) components. The sample scene uses a custom [Surface Tool](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/surface-tool) to simulate a crude wave effect to demonstrate how you might connect Surface Tool to whatever water/ocean simulation tool you prefer to use.

The example [Surface Tool](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/surface-tool) (WaveSurface) defines the surface of the volume and the density of the volume.

The [Buoyancy Body](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/buoyant-body) uses the Surface Tool along with the Buoyancy API to calculate and apply a buoyant force on the attached body.

The [Buoyancy Body Drag](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/buoyant-body-drag) tool works with the Buoyancy Body to modify the applied drag on the body causing it to experience more drag the more "water" its drafting.

## What do I Learn?

1. How to access the [Buoyancy API](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/api/buoyancy) from your scripts
2. How to use [Buoyancy Body](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/buoyant-body)
3. How to use [Buoyancy Body Drag](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/buoyant-body-drag)
4. Hot to create and use a custom [Surface Tool](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/surface-tool)

## Objects

### Test Float

The scene has 4 Test Float objects

* Test Float (Player)
* Test Float (1)
* Test Float (2)
* Test Float (3)

The Test Float objects implement the [Buoyant Body](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/buoyant-body) and [Buoyant Body Drag](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/buoyant-body-drag) components which them selves require and apply a [Physics Data](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/physics-data) component. These 3 components allow the objects to float on the surface of the Ocean component which implements a Surface Tool.

#### Test Float (Player)&#x20;

This float object implements an addition sample script which serves as a crude player controller e.g. moves when the WASD keys are pressed.

### Cubes

The scene has 320 cube objects equipped with the same basic behaviors as the board configured to use a fast float. These simply serve to demonstrate the efficiency of the effect.

### Ocean

The Ocean object implements the custom script WaveSurface which is a sample implementation of the [Surface Tool](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/surface-tool).

#### WaveSurface.cs

This script is a crude example for a water/ocean [SurfaceTool](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/surface-tool). Typically your custom SurfaceTool would simply find the depth from surface at any given world point. This sample script does that and also simulates a simple wave effect.

To learn more about [Surface Tool](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/surface-tool) please see the [Surface Tool Article](https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/components/surface-tool).
