Zibra Liquids: Watermill tutorial

Using Zibra Liquids, our AI-powered solution for real-time fluid physics simulation, we set up a 3D scene and adjusted the liquid interaction with its surroundings using the Force interaction feature in just 10 minutes. Water transfers power to the mill, making it spin automatically. Would you like to create the same scene in Unity by yourself? Then let’s start!

This demo shows you how to configure the interactive liquid, make an infinite flow, set up the visual quality parameters, and create gameplay mechanics.

Preparation

1. Create a 3D scene in Unity. (Optional) Download the scene with all meshes already in place. You can find the links below. In that case, skip straight to the Creation of a Zibra Liquid simulation.

2. Download Zibra Liquids and all the necessary props.

3. Create two segments as pictured below. Duplicate the small one to build a river of any length.  

4. To customize the river, load it into any suitable 3D editor. We used Blender.

5. Let’s get to work on the mill. Select all the necessary elements in the mill and remove the elements that you won’t use. Note that the wheel should be a separate mesh from the house. 

6. Export our models to Unity and build the environment in the scene.

Creation of a Zibra Liquid simulation

1. Now we have to set up the water. To do that, first import the Zibra Liquids package.

2. Add the Zibra Liquid container and the Zibra Liquid Emitter. This is a minimum required setup.

3. Press the play button and you will see the fluid in action (it flows inside of the invisible box):

4. Set up the space where the water will work. Set up the container borders:We place the container only in the working area. It is advisable not to stretch the container too much over the entire scene. The smaller the volume, the better the liquid quality will be. The container size that we use in the scene is X75 Y10 Z230.

When setting the liquid resolution, keep in mind that it affects the quality of the water. Be aware that too high of a resolution may hurt the performance of the game. We set the resolution to 500.

5. Place two Voids along the river banks. They will absorb the water that has poured out. Place another Void above the mouth of the river so that it takes on any excess water. Void is a liquid exit point from the scene.

6. Set up the Fluid Emitter – a liquid entry point into the scene.

The number of particles per second is proportional to the amount of water. We adjust the Emitter so that the water does not reach the wheel. In our case, it is 3000 particles per second.

Adjusting force interaction

1. Now let’s deal with the stones that will be part of the game mechanic. Add the stones. Set up the Zibra Neural Colliders on the stones (In case you missed it,  we recently replaced Voxel Colliders with Zibra Neural Colliders).

2. Add Mesh Colliders and Rigid Body to the entire environment so that the stones do not fall through it. Now our stones can interact with water and block the flow of the river.

3. Add a Neural Collider to the wheel and a Rigidbody for wheel physics. In the Neural Collider set the Fluid Friction to the maximum. This allows the wheel to interact more stably with water.

Rigidbody settings

To make the wheel spin only on one axis, make a freeze position and a freeze rotation.

Set the weight of the wheel to 20,000. This value depends on the object complexity and the amount of water, so feel free to experiment to get the best result.

(optional) Scripting 

1. Add scripts to make the scene more dynamic. The first one allows you to rotate the camera around the scene.

2. The second script allows you to move the stones in the scene with the mouse or touch screen.

(optional) Visuals setup 

1. Use ready-to-use presets to adjust the look of your liquid.

 

2. All that’s left is to set up the light in the scene.

3. Add Cubemap to make reflections on the water. Bake the Reflection Probe.

4. Add Reflection Probe to liquidity settings.

If you have any questions, please join our Discord. We will gladly answer your questions.

Video tutorial