WaterObject
is the main SceneComponent
of the Dynamic Water Physics 2 for Unreal Engine. It handles all the aspects of simulating the interaction of the object with water.
WaterObject
needs to be attached as a child of UStaticMeshComponent
. This is because the mesh data is used for simulation. Below are a few examples of blueprint hierarchies that can be used:
WaterObject
always retrieves mesh data from the first parent UStaticMeshComponent
. However, the resulting forces are applied to the first UPrimitiveComponent
in the hierarchy with Simulate Physics enabled that the script comes across, iterating from itself towards the scene root. An example of this:
WaterObject
uses mesh data (vertices and triangles) to calculate the correct physics forces. This means that the performance of the WaterObject
is directly proportional, O(n), to the number of triangles present on the mesh. Most LOD0 meshes have an unnecessarily high number of triangles for this use so using LODs is recommended.
There are two settings:
Mesh LOD
- defaults to -1 which tells the script to use the highest available LOD (lowest detail).Mesh Section
- defaults to 0 and tells the script which mesh section to use.
Generally adequate triangle count for different shapes:
For most shapes around 16-32 triangles is adequate and as long as the mesh roughly represents the object shape increasing the number of triangles will not improve the quality of the simulation.
LODs in Unreal can be edited by double-clicking the mesh in the Content Browser and selecting the LOD through the LOD Picker (Details sidebar):
If the LOD dropdown does not have any options, make sure that the LOD Group is set (under LOD Settings foldout).
To adjust the number of triangles on the LOD adjust the Percent Triangles slider until the wanted triangle count is achieved. By default with the Mesh LOD
of WaterObject
set to -1 the highest LOD will be used, which in this case is LOD 3.
By default WaterObject
uses Default Water Height
, Default Water Normal
and Default Water Flow
. These three settings can be adequate if the water is flat and uniform across the scene. However, if using a non-flat water WaterObject
needs to know where the water is. This is done through WaterData
components.
The base class is UWaterDataBase
which can then be overridden to implement support for different water systems, such as the included UWaterDataUnrealWater
.
WaterObject
⇒ Query Single Point
can be used to maximize performance.A quick step-by-step guide for setting up the barrel from the demo:
Static Mesh
under the Details panel to barrel_Oildrum-ref
.Static Mesh
to open the mesh editor. Add Component
and then on Water Data Base
or Water Data Unreal Water
, depending on the water used.