19-05-2021, 04:49 PM
(This post was last modified: 19-05-2021, 04:57 PM by DryGinStudios.)
(19-05-2021, 07:44 AM)josemendez Wrote: There isn't any physical attribute (mass, density, etc) that you can change to make an object "move faster", in absence of external forces/accelerations. Not fluids, not any other body (eg. rigidbodies). Unless a external agent changes their velocity, all objects will keep moving with whatever velocity they currently have. This is a fundamental law of physics, and applies to all physics engines: if you create a sphere in Unity, there's no parameter that will let you control how fast it rolls down an inclined plane for instance.
You can always change the velocity of individual fluid particles, using the particle API:
http://obi.virtualmethodstudio.com/tutor...icles.html
You can also change Unity's timescale to a value > 1, for a "fastforward" effect to all physics in your game.
Timestep and iterations control quality vs performance in all existing physics engines, Obi is no exception. The manual's introduction section contains an in-depth explanation of the impact these have in the simulation:
http://obi.virtualmethodstudio.com/tutor...gence.html
Timestep size: there's two ways to change the timestep size: changing Unity's fixed timestep value (found in ProjectSettings->Time, this will affect all physics in your scene), or by using more substeps in Obi (found in the ObiFixedUpdater component, this will only affect Obi). Using more substeps will chop up the fixed timestep into a number of smaller "substeps", resulting in a smaller effective timestep size.
Iterations: can be changed in the ObiSolver component. You can individually tweak the amount of iterations spent on each constraint type, see:
http://obi.virtualmethodstudio.com/tutor...olver.html
In Unity's physics engine you can also adjust the amount of iterations, you can find them in the physics manager: https://docs.unity3d.com/Manual/class-Ph...nager.html. However it only differentiates between position and velocity iterations, so it doesn't give you nearly as much control as Obi does.
Note that time stepping and iterations are basic simulation concepts, that you should already be familiar with if using an advanced engine such as Obi. They are the foundation on which all physics engines are built, you can find lots of online resources regarding this: https://www.reddit.com/r/Unity3D/comment...terations/
Constraints are the main performance bottleneck in any physics engine. The more constraints are there in the scene, and the more time the engine spends enforcing them, the costlier the simulation. For instance, if you have 1000 rigidbodies colliding with each other in Unity (each contact between 2 bodies is a constraint), the simulation will be much more expensive than having 1000 rigidbodies that don't collide at all. Also, using 6 iterations means the engine will go over all constraints 6 times per timestep, which is more expensive than iterating 5, 4, 3... times.
All of this is common to all physics engines. The manual does not aggregate every performance-sensitive parameter in a single place, however when a parameter affects performance, the manual explains what the tradeoff is. Keep in mind that timestep size and iterations are the most important ones.
Ok, thanks for all the information! I'm tweaking performance and I continue my prototype. I got one quick question. I'm trying to put textMeshPro over the liquid and it's not working. I even tried 2 camera but the liquid is draw on both camera even if I put NONE for culling mask. How can I put textmeshpro over the liquid? Thanks!
Oh yeah last question (sorry I ask so many questions). I see in the maze example that we can check for OnCollision and I integrated it and it work but what I need is more a OnTriggerEnter and OnTriggerLeave to know how many of the liquid particles are in the zone. What is your suggestion for the best way of doing this?