# 1 Buoyancy Example

{% hint style="success" %}

#### Like what your seeing?

Support us as a [GitHub Sponsor](/old-kb/where-to-buy/become-a-sponsor.md) 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](/old-kb/where-to-buy/become-a-sponsor.md) ... become a sponsor today!
{% endhint %}

## Introduction

![](/files/h7Bw0oXH9TYplqujrhcK)

This scene demonstrates the use of the [Buoyancy Body](/old-kb/toolkit-for-physics/physkit/components/buoyant-body.md). [Buoyancy Body Drag](/old-kb/toolkit-for-physics/physkit/components/buoyant-body-drag.md) and [Surface Tool](/old-kb/toolkit-for-physics/physkit/components/surface-tool.md) components. The sample scene uses a custom [Surface Tool](/old-kb/toolkit-for-physics/physkit/components/surface-tool.md) 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](/old-kb/toolkit-for-physics/physkit/components/surface-tool.md) (WaveSurface) defines the surface of the volume and the density of the volume.

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

The [Buoyancy Body Drag](/old-kb/toolkit-for-physics/physkit/components/buoyant-body-drag.md) 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](/old-kb/toolkit-for-physics/physkit/api/buoyancy.md) from your scripts
2. How to use [Buoyancy Body](/old-kb/toolkit-for-physics/physkit/components/buoyant-body.md)
3. How to use [Buoyancy Body Drag](/old-kb/toolkit-for-physics/physkit/components/buoyant-body-drag.md)
4. Hot to create and use a custom [Surface Tool](/old-kb/toolkit-for-physics/physkit/components/surface-tool.md)

## 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](/old-kb/toolkit-for-physics/physkit/components/buoyant-body.md) and [Buoyant Body Drag](/old-kb/toolkit-for-physics/physkit/components/buoyant-body-drag.md) components which them selves require and apply a [Physics Data](/old-kb/toolkit-for-physics/physkit/components/physics-data.md) 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](/old-kb/toolkit-for-physics/physkit/components/surface-tool.md).

#### WaveSurface.cs

This script is a crude example for a water/ocean [SurfaceTool](/old-kb/toolkit-for-physics/physkit/components/surface-tool.md). 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](/old-kb/toolkit-for-physics/physkit/components/surface-tool.md) please see the [Surface Tool Article](/old-kb/toolkit-for-physics/physkit/components/surface-tool.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kb.heathen.group/old-kb/toolkit-for-physics/physkit/sample-scenes/1-buoyancy-example.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
