Skip to content

class_waterarea

jonri edited this page Oct 28, 2023 · 4 revisions

This file is automatically generated. To make changes, please edit the corresponding xml file in the doc_classes/ folder instead.

WaterArea

Inherits:

Defines an area in which a HydroRigidBody will be affected by buoyancy and related forces.

Description

The purpose of the WaterArea node is threefold. First, it limits the area in which a HydroRigidBody is evaluated for potential buoyancy. This means that if you only need water in a small area of your scene, the HydroRigidBody will not incur a performance penalty while it is outside the bounds of the WaterArea.

The second purpose of the WaterArea is to define the surface of the water. For a flat body of water, set the water_height parameter to the global-space height of the water. For a body of water with waves or any other advanced scenarios, attach a script to the WaterArea and define a _get_water_heights(positions) function. The positions parameter is a PoolVector3Array. For each Vector3 in the array, adjust its Y value to the height of the water at the given X and Z position. The return value of the function should be the PoolVector3Array with the Y-values changed. When this function is defined, the water_height parameter is ignored.

Finally, the WaterArea acts as a standard Area node. It can be used to trigger sound or particle effects to make an object splash when it hits the water.

Properties

Property Descriptions

  • float density
Setter set_density(value)
Getter get_density()

Sets the density of the water in this area. Freshwater is 1000 kg/m^3, and seawater ranges from 1020 - 1029 kg/m^3.


  • Vector3 flow_direction
Setter set_flow_direction(value)
Getter get_flow_direction()

Creates a uniform current running through the area in the specified direction. Any object submerged in this area will be pushed in the direction of the current.


  • float viscosity
Setter set_viscosity(value)
Getter get_viscosity()

Adjusts the viscosity of the water in this area. This value changes the resistance to motion through the fluid without affecting buoyancy. The default value of 1.0 is a good starting point for water; for thicker substances such as maple syrup or lava try increasing the value.


  • float water_height
Setter set_water_height(value)
Getter get_water_height()

Sets a constant global-space water height. This value is not used if you create a custom wave height function instead.