It has been a slow week for the project. But I managed to squeeze in some time to add water and player and rigid body interactions and test and implement shallow waters into the game.
Previously I was using Unity’s built in plane for the water, but for the shallow water I needed smaller polygon size for more detailed interactions with the player character. So I created a 100by100 polygon plane so I would not need to render so many separate water planes.
The idea here is to create support for puddles, rivers, pools and other shallow water bodies with interactions for moving objects, mainly rigid bodies. The system does not require the interactive object to be rigid body though, it just needs to move.
The velocity of the object is also a factor in how big of a wave is drawn into the water. So when walking, there is hardly any waves, but once you run, there is a much more pronounced impact on the water surface. I will keep tweaking these values as the project advances.
As seen in the video above, the way the water works is that an infinitely looping fluid render texture covers the whole world. Objects then interactions with this object in world space with their position being looped in sync with the render texture world position. Only gameobjects seen by the camera add interactions to the water, so things off screen do not add waves to the texture.
I still have not implemented an “on / off” switch for the interactions when the objects touch the water. At the moment they will always (when rendered and moving) add interaction to the water plane. But adding condition for checking when the objects actually collide with the water will be next.
The objects also do not float in the water yet. I will also be adding support for buoyancy later.
The water does not yet work in build, so that is a major issue I need to fix before I can celebrate. As I have no idea why,