Stylized Water 2 documentation

Stylized Water 2

Stylized Water 2
Author: jonathan
Version: 1.0.6
Dated: 22 Sep 2020

5.Buoyancy #

The package comes with scripting functionality that allows the water surface height and orientation to be read. This in turn can be used for buoyancy calculations. Note that this implementation primarily provides the necessary functionality for third party/custom buoyancy functionality. It does not feature boat controllers or true physics-based buoyancy.

The wave height and normal can be read at any world position using this static function:

StylizedWater2.Buoyancy.SampleWaves(Vector3 position, Material waterMat, float waterLevel, float rollStrength, out Vector3 normal);

It’s performance efficient, and uses the Unity Mathematics package if installed. 100 individual buoyancy samples takes about 0.01ms in total with one wave layer.

For buoyancy to work, on the material the “UV Source” under the Rendering tab must be set to “World XZ projected”

Floating Transform

This component makes a GameObject and all of its child objects float on the water.

Because the script sets the orientation of the Transform, modifying all axis, it cannot be rotated manually or through other scripts. Instead, set the rotation of the child objects directly. The position (X/Z value) can be changed freely.

Hierarchy set up when looking to modify the rotation, on top of the wave orientation

 

 

 

 

 

 

The “BuoyancyExample” scene shows this component in action

Dynamic Water Physics 2

This integration is pending, and will be available in DWP2 version 2.3.1+. If you’d like to have the integration script now, please get in touch

The DWP2 asset is an advanced buoyancy system, that includes a boat controller for moving an object on the water surface, while also performing buoyancy. An integration is included, that allows them to be used together.

To install the integration, see the Third party integrations section.

By default, the DWP2 water object will use a FlatWaterDataProvider component. Remove this, and add the StylizedWaterDataProvider component. You will have to assign the water material you are using, since this script requires to know what kind of parameters are used for the waves.

For any further details, please refer to the DWP2 manual…

Yes No Suggest edit
Last updated on January 14, 2021
0 of 0 users found this section helpful
Suggest Edit