- Home /
Water physics in solid object
Lets say there is "water" in a still cup (water is also still) and the cup starts to move (there is a force applied to the water in the opposite direction of the cup movement) and then the cup hits a wall (water splashes up and possibly out of the cup). Would this be possible to simulate?
I have tried looking this situation up on google and on this site but did not get a clear answer.
I do understand that simulating water physics is very complex and would require collisions between each particle to exist. Not sure if this type of situation would require physics for the water or if it could be resolved in a round about way
New to the website and unity. Appreciate any sort of help given!
Answer by Soraphis · Nov 18, 2015 at 01:09 PM
there is a force applied to the water in the opposite direction of the cup movement)
not true actually, the water is inert. And there is a force applied to the water in movement direction (from the back wall of the cup). But to your problem:
You want to simulate the water as particles. Think about filling a cup not with water but with many, tiny spheres (you can think about it as water molecules). With these spheres you can simulate inertia and forces to the water. And with an shader you make it look like water.
https://en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.121.844&rep=rep1&type=pdf
https://software.intel.com/en-us/articles/fluid-simulation-for-video-games-part-1/
But this isn't that easy, and can really be an hit to performance. You should consider faking it, instead simulating it:
The water in the cup being just a plane with many vertices. Everytime a force is applied to the cup you manipulate the water-plane-vertices. Reducing the height of some at the front (nearest to movement direction) and increasing the height at the end. the height of all vertices added together needs to stay constant.
This isn't easy either, because it needs some afford to make it look nice and realistic.
Answer by KdRWaylander · Nov 18, 2015 at 12:13 PM
Hi,
To my knowledge, there is no physics of particules (water, sand, ...) in Unity (yet?) ! However, you can still achieve some cool stuff using Particle Systems (the same way you do smoke, fire, ...): every time your cup hit the wall you throw a water effect.
More informations:
https://www.youtube.com/watch?v=G-K2rtiv80M (you'll find dozens of tutos on Youtube)
Cheers
Your answer
Follow this Question
Related Questions
How to make physics collision dotted simulation like bubble shooter ? 2 Answers
How to do particle collision 2 Answers
Make a particle system with particles that stick to everything once they collide 0 Answers
C# Custom Collision Script (solved) 1 Answer
OnCollisionStay only detects collisions after a secondary collision 0 Answers