User Tools


Water Object

WaterObject inspector.

Water Object is a script that sets up the object for simulation. All the objects containing Water Object will interact with water if there are no setup errors and Water Object Manager is present. Water Object requires the object to have a Mesh Filter present (mesh renderer is not needed). Water Object uses a Simulation Mesh that is an (optionally) simplified mesh.

Fields

  • Simplify - Should the simulation mesh be simplified? If the mesh has more than 30 triangles it is usually a good idea to enable this option.
  • Target Triangle Count - How many triangles the simplified simulation mesh will have?
  • Convexify - Should the simulation mesh be made convex? While DWP supports both convex and concave shapes, enabling this option is recommended when there are holes in the mesh (e.g. a crate without the top or a ship hull without deck). In some cases it can also be used to lower the triangle count additionally.
  • Update Simulation Mesh - Generates the simulation mesh from the given options. If Simplify and Convexify are left unticked the original mesh will be duplicated.
  • Toggle In-Scene Preview - Besides using the preview icons inside the inspector it is also possible to preview the simulation mesh inside the scene. When clicked this button will toggle between original and simulation mesh on the current object. Material Settings (only available if Rigidbody has Rigidbody Mass From Children component attached):
  • Material Preset - A list of common material densities. When selected Mass will be calculated from the auto calculated volume of the mesh (scale-sensitive) and the selected material density. Set this field to Custom if you want to use a custom density or mass.
  • Density - Only available if Material Preset is set to custom. Density in kg/m3. Setting this field will update the Mass field.
  • Mass - Only available if Material Preset is set to custom. Mass in kg. Setting this field will update the Density field.
  • Volume - Auto-calculated volume of the mesh. If you scale the mesh or otherwise change it click Update Volume to make sure it is up-to-date.

Instantiating at Run-time

When Water Object is added to the scene during play mode it will not be automatically registered because this requires re-allocating memory for the jobs.

To add WaterObjects to the scene at run-time first instantiate them and then call WaterObjectManager.Instance.Synchronize(); This will signal to Water Object Manager that all the objects are instantiated and that it can synchronize the data.
Alternatively, WaterObjects can be instantiated on Awake and disabled. Water Object Manager will by default run Synchronize() in Start() and will register Water Objects even if they are disabled - and those objects can then later be enabled without calling Synchronize(). Disabled Water Objects incur no overhead and you can enable/disable them at will.