Water plugin - Movable water bodies?

Leaving this here if anybody is also trying to adjust ocean level during runtime. After hours of digging into the Water system I figured out a way.

There are 2 ways to achieve this:

Method 1:
Use command variables to force mesh update per frame (as @Psy2099 mentioned above)
This is easier. Downside is that this doesn’t update post-process materials, so if you’re not going underwater this is fine.

  1. Set r.Water.WaterMesh.ForceRebuildMeshPerFrame to 1
  2. Open the water surface material (WaterBodyActor → WaterBodyComponent → Water Material), set “UseFixedZ” to true, so that it updates with the frame’s rebuilt mesh.
  3. Set the component’s mobility to movable in BP to movable, then simply set the height of water body using BP, it shoud update.

Method 2:
Change the internal material setup to force water render at desired height.
This is simpler, as it takes care of water surface and post-process materials altogether. Basically we are setting the MPC parameter, and then changing the water material to adjust height according to the parameter. This only takes care of the rendering part, so if your waterbody needs to interact with objects, you’ll need to combine method 1&2.

  1. Locate the “WaterBodyData” material function (Engine/Plugins/Water Content/Materials/Functions).
  2. Replace “FixedZHeight” parameter node to CollectionParameter. Collection: MPC_Water, Parameter Name: WaterZ
  3. Open Water surface material and post process material, both needs to have “UseFixedZ” to true
  4. Set material parameter collection’s value using “Set Scalar Parameter Value” in BP. Set “WaterZ” value to your desired height. The water should render at the height without the need of moving/rebuilding mesh.
2 Likes