Stylized Water 2 documentation

📣 UNITY 6

Reminder: this asset is developed for use with Unity 2020-2023.2

Stylized Water 3, for Unity 6, is available now!

If you have purchased a license for Stylized Water 2 less than 45 days ago you are able to upgrade for free! This option will be available until December 31st 2024. (upgrades are a fixed system, no exceptions can be made by either me or Unity staff)

A 25% upgrade discount will remain in effect until June 2025.

Stylized Water 2

Stylized Water 2
Version: 1.6.9
Review

5.Buoyancy #

Reading wave data through C#

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. Familiarity with scripting is assumed in order to understand how to use this. If you’re set on making a buoyancy system, understand that it’s potentially a complex task.

This API primarily provides the necessary functionality for third party or custom buoyancy systems. This asset does not feature boat controllers or true physics-based buoyancy, which falls outside of its scope.

Reading wave heights will only work for flat water bodies. Rivers or spheres are technically not possible without some complex scripting magic, this starts to delve into a custom physics system.

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, bool dynamicMaterial, out Vector3 normal);

The function has a summary, you can view a description for each parameter in your IDE, as well as any overload functions.

  • For buoyancy to work, on the material the “UV Source” under the General tab must be set to “World XZ projected” (that’s default)
  • The returned information is likely far more accurate than the visual representation of the water mesh. It does not actually return the height/normal of a mesh’s triangles.
  • If you are using an assembly definition, ensure you add a reference to the sc.stylizedwater2.runtime assembly, otherwise you won’t be able to access the StylizedWater2.Buoyancy class.

Dynamic Water Physics 2

The DWP2 asset is an advanced buoyancy/hydrodynamics system, that includes a ship controller. An integration is included, that allows it to be used with Stylized Water 2.

To install the required Stylized Water Data Provider component, see the Third party integrations section.

Water setup

By going to Help->Stylized Water 2->Hub Window you can quickly set up this component

Manual instructions:

By default, the DWP2 will rely on the Flat Water Data Provider component to identify and read a body of water’s surface.

Remove this, and add the Stylized Water Data Provider component to your lake/ocean. 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.

When using the Stylized Water Data Provider component, DWP2’s systems can use it to query the wave height/orientation at any given point. Under the hood, this simply uses the Buoyancy API outlined above.

 

For any further details, please refer to the DWP2 manual… (I’m not the author)

Yes No Suggest edit
Last updated on December 14, 2023
6 of 6 users found this section helpful
Suggest Edit