Links
Comment on page

1 Buoyancy Example

Like what your seeing?

Support us as a GitHub 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 ... become a sponsor today!

Introduction

This scene demonstrates the use of the Buoyancy Body. Buoyancy Body Drag and Surface Tool components. The sample scene uses a custom 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 (WaveSurface) defines the surface of the volume and the density of the volume.
The Buoyancy 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 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. 1.
    How to access the Buoyancy API from your scripts
  2. 2.
    How to use Buoyancy Body​
  3. 3.
    How to use Buoyancy Body Drag​
  4. 4.
    Hot to create and use a custom 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 and Buoyant Body Drag components which them selves require and apply a 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)

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.

WaveSurface.cs

This script is a crude example for a water/ocean SurfaceTool. 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 please see the Surface Tool Article.