This guide works with Unity 2019+. If you need to install it in Unity 2018 even though it has been uploaded with a newer version, it is also supported. There is a lot of conditional code in order to make it work. A manual install is necessary, not only the asset itself, but since v2.1 the required packages listed below can't be installed via the Package Manager and should be added manually too.
First of all, to avoid compilation errors, WaveMaker requires 4 additional packages to be installed manually in your project. You will have warning messages on the components if any package is missing:
If you don't know how to install packages or have problems finding them:
After installing the required package versions, download and install WaveMaker into your project. Use the manual page to learn how to download and install this asset from the Asset Store.
To check if everything is working right, open the Quickquide in pdf included in the main folder and follow the guide, or open one of the many Sample Scenes included and hit play.
WaveMaker requires some packages to be installed. To fix them, please visit the How to Install guide
v2 WaveMaker lies inside an assembly called WaveMaker. In that file the versions of the required packages are detected. This error arises just after importing the package, and seems like it can't detect the packages in some files and doesn't create the correct Visual Studio files. Delete .vs folder, and visual studio files (.csproj and .sln) in your project, and open the code again. It will regenerate the files. If it still doesn't work, you will have to clean up the Unity cache (delete Library folder, and Temp files) in the project folder and reopen the project. If it still persists, please contact me.
How do I create a liquid surface or an object to interact with it?
Use the quickstart pdf file included with the asset, or visit the tutorial section
What is that Descriptor file needed to initialize a WaveMaker Surface? How do I create it?
Visit the descriptor section to read about this file.
My interactor does not affect the surface!
Check if any of these is false:
In Occupancy mode with buoyancy enabled my objects fall anyway
WaveMaker applies forces to objects with rigidbodies the same way the Unity physics engine works.
It looks like some floating interactors fly above the surface.
The objects are virtually bigger to smooth out the interaction with the surface. This happens when your interactor is not too heavy. To avoid this, just increase the mass of the object's rigid body.
Some floating interactors never seem to stop rotating and moving
Forces are not continuous but discrete, meaning they are applied on the surface grid and generate unrealistic movements in some colliders. Try these solutions:
This is a typical problem on any simulation. Some parameters will make the simulation unstable creating weird and increasing errors in play mode.
If you need higher resolution, you will have to keep your propagation speed low to avoid the warning. The problem with this is that waves will move very slowly. To fix this, set subtepping to 2 or maybe 3 maximum. This will allow to increase the propagation speed to the look you like.
But be warned: This will make the simulation take more processing time. Consider reducing resolution and try to keep substepping to 1.
Velocity based interaction compares relative velocities between the surface and the interactors. You can use the settings in the Interactor component of your object to enable velocity smoothing and showing it in the scene view on play mode to check if you like it.
Why WaveMaker doesn't use Compute Shaders to create the mesh without limits and a fast simulation?
This is a very common question. There are other assets in the Asset Store that do this, but lack some of the features WaveMaker has.
Using Unity meshes has the limitation of 56k triangles (that means for example 256x256 resolution in a square surface). Compute shaders would allow WaveMaker to have bigger and faster meshes generated inside the GPU.
Why not use the GPU? The reason for this is simple, for now: The Occupancy interaction mode that allows Buoyancy is a two-way coupling system: the surface affects the interactors, which are Unity rigidbodies, and colliders can affect the surface at the same time.
In order to affect colliders outside the GPU, interaction data should be extracted from it, which is a very slow (at least in my experience) and would absolutely destroy efficiency. In Compute Shaders all should be done inside the GPU, absolutely everything.
Since we use Colliders and WaveMaker doesn't implement a whole physics engine inside the GPU, which would go out of the scope of this asset, we can't really use compute shaders. There is a possibility to move the Velocity interaction mode, which is a one-way coupling, into Compute Shaders in the future, but right now there is a lot of room of improvement with Burst and Jobs and it is pretty fast for now.
A surface is a game object with a WaveMaker Surface component and it shows a mesh and simulates it. The mesh and all needed components are automatically created and the mesh is updated each frame.
Create a surface fast using "3D Object -> WaveMaker -> (choose simulation type) -> Surface" in the GameObject menu or right clicking on the Hierarchy view.
The interactors are game objects with a WaveMaker Interactor component. They can interact with the surface to make it move. They can also be moved by the surface in certain cases.
Create a basic sphere / box / capsule interactor using "3D Object -> WaveMaker -> (choose simulation type) -> Interactor" in the GameObject menu or right clicking on the Hierarchy view.
When using Velocity based interaction, if your interactor moves very inconsistently (trembling, violent movement), you can use the velocity parameters to smooth out the velocity and see how it looks.
These will make simulation look wrong.
As soon as you create a WaveMaker Surface component, you will be asked to attach a Descriptor file. This scriptable object file is stored in your project and can be created in the Project View via the right click Create menu.
Descriptors store the resolution as well as the cell's properties. They can be shared between surfaces.
As soon as you attach the file, the mesh will be created and the parameters will be available. When modified, via the Inspector of the Descriptor or via the Wave Maker Surface component, all Surfaces using that Descriptor will be updated.
The size of the Surface can be set via these values in the Surface component. You can also set it using the scale of the game object, but since the transform's scale can be affected, it is recommended to set it via the local mesh size box, independent of the transform.
These parameters affect the simulation of the water even when there are no interactors touching it or which interaction type is selected
By default set it always to 1. Increase it ONLY if you see a warning or the fluid is unstable. This happens when the resolution is too high or the propagation speed for that resolution is too high. A warning is shown in the surface component. Reduce resolution, reduce propagation speed or increase the value until the warning dissapears. Every FixedUpdate() the fluid simulation will be executed this number of times, so try to keep this value low!.
Affects EfficiencyThe speed of the waves. A warning will appear if the value is too high for the current resolution. For very high resolutions it is not possible to set a big speed value. If you need more and you can't reduce resolution, incresase the substeps by using the Substep parameter.
Affects stabilityHow fast waves dissapear in the surface. This will make your surface look creamy or like mercury. A value of 0 will never allow the surface to get asleep. A very extreme value could cause inestability, but in very excepcional cases.
To reduce mesh noise and spikes in the surface if you don't like how it looks, you can increase resolution or use this parameter (as well as shaders!). In general you need a very high value to see the effect.
This parameter generates unrealistic fluid effects and should not be used as a substitute to propagation speed. This will let you create slow-down and speed-up effects.
This important choice changes the way interactors change the surface. The choice affects tremendously the efficiency of your scene and memory usage, so be sure to understand both methods!
Available from v1, this method detects interactors touching a very thin layer around the plane and compares relative velocities between the surface and the interactors in order to generate the waves.
This method is the fastest one of all, and its efficiency has been improved since v1 tremendously. Depending on the resolution of your surface (via Descriptor file) and a good choice of parameters to allow it to get asleep, you will be able to add many of them in the same scene.
When should I use it? If you just need water simulating or you want to add many of these in your scene. It allows for all sorts of orientations and positions inside any hierarchy. You will not have advanced features like buoyancy, drifting and others. This will suffice for most of the cases.
New in v2, this new method takes into account a box of space underneath the surface that detects interactors and calculates how much volume they occupy.
Since the occupancy is calculated, apart from the waves generated by the objects, we can use that to generate a bunch of advanced effects like floating forces (buoyancy) and drifting forces (horizontal floating forces) and much more that will come in future versions.
When should I use it? In general, horizontal surfaces where you need the advanced features like buoyancy or drifting. Be aware that they get asleep less often if objects are floating on them. Otherwise, always use the Velocity mode instead, which runs a lot faster and consumes much less memory.
There is no default value for these. Play around with values. Since this effect is based on a fake physics effect, you can use these to scale the size of waves generated by horizontal movement and vertical movement relative to the surface. Set to 0 to remove any of them.
Since this method compares relative velocities between surface and interactors, huge waves can be generated due to very high speeds. To avoid huge waves, set to a speed in units per second that cannot be exceded.
Since this method compares relative velocities, this will ignore any interactor that moves relative to the surface at this given speed in units per second. Useful to ignore tiny differences and keep the surface asleep.
How deep the volume is. A collider is created in play mode going as deep in Unity units as selected. To improve numerical precision keep it as small as possible, but set the size so any interactor touches the bottom. If objects leave or enter the box through the bottom, waves will be generated on top.
If disabled, the surface will not be modified by interactors and will stay flat. This improves efficency, and can be used in cases where you only want buoyancy. Disabling buoyancy too will make no sense, in that case, disable the whole component.
Affects EfficiencyWaves are generated more realistically with this interaction method, but you can use this parameter if you want smaller waves (less than 1) or bigger waves (more than 1). Keep the value at 1 by default.
Set this to what you calculate will be the maximum number of interactors touching this surface at the same time. The smallest, the fastest the simulation and the less memory occupancy. If set wrong, some will be ignored and simulation / occupancy calculation could have unexpected outcomes. An error is output if the "Warning log" is enabled.
Affects EfficiencyEach interactor inside the area underneath the surface will have a number of cells assigned in the X-Z plane. If the value is too low, noise will happen on the surface and objects will not fully float. If the "Warning log" is enabled, you will see warnings whenever this happens. This value has to be the smallest you can to optimize the computations, so use the log to test your bigger interactors.
Affects EfficiencyUsing the rigidBody mass, the density of the surface liquid, forces will push the object upwards until it is stable. Otherwise objects using gravity will pass through it.
Affects EfficiencyApart from vertical forces, other forces will be generated by the waves touching the interactors, moving them around the surface horizontally.
Affects EfficiencyUsed to smooth out the buoyant forces that can generate infinite jumps or non-stoppable rotations that can occur on some types of collider shapes. To change this individually you can just increase the Drag on the rigid bodies.
Set to 1 by default. Use a real density value to make objects float using it. You must combine it with wave simulation properties to make it look realistic. Find the values online (Water is 1, Oil is 0.92, Mercury is 13.60, etc). High density fluids will make interactors float a lot, lower values will not have that strength to rise objects.
Keep this log enabled while developing your project to ensure your settings are correct in Occupancy Mode. It will guide you when objets detected are too big than the number of cells you set or more than the allowed amount of interactors are detected, etc.
Affects EfficiencyUnity in WebGL doesn't support multithreaded code. These live demos will execute slower depending on your computer but at least you can play with them online.
© 2024 Lidia Martinez Prado - http://www.lidia-martinez.com