- Home /
iBeer/Liquid Type Effect - iOS
Hello,
I'm sure you've all seen these mobile apps 'iBeer', and 'Carling iPint'. Where the phone is basically a liquid that follows the device's accelerometer. Which gives the effect that you are essentially 'drinking beer from your phone'.
Does anyone know how to achieve this within Unity? After taking a closer look at the apps, it's not actually using a liquid engine, but more of a mesh texture that pulls its vertices along with the device rotation.
I would appreciate any input on this subject. Thanks.
Answer by Eno-Khaon · Aug 14, 2015 at 07:56 PM
There are numerous ways to try and tackle this. Since those are often 2D-based, it simplifies the calculations considerably.
Here are two ways to approach this:
1) Liquid surface mesh-based approach: Starting this involves understanding ways of creating the initial water motion as a mechanic. You start primarily with a surface, then move the liquid around based on the motion of the surface. While it might not necessarily be ideal for what you're working at, it may still be worth investigating to learn how to handle a smooth surface, since that can be combined with...
2) The metaball approach: Rather than having a pre-determined mesh to begin with, instead use a collection of sphere/circle (for 3D/2D respectively) colliders and rigidbodies to determine the current state of the liquid. As the colliders interact, they can transfer some of their volume (4/3πr3 for 3D or πr for 2D) to other nearby colliders for variable fluid quantities in motion at a time. Then, construct a mesh around them with generalized smoothing between major groupings to fill in illogical gaps (such as a particularly uneven surface). Then, the orientation of the phone/tablet can reorient the effective direction of gravity to pull the colliders in whatever the current "downward" direction is at the time.
It's definitely not the simplest task to make it and make it look good, but very interesting effects can come from getting it to work well.
Thank you for this. This covers how to get a mesh to respond in a liquid matter, but what about getting the mesh to follow and behave appropriately when inside a container that is rotation? (via accelerometer)? Thanks.
Your answer
![](https://koobas.hobune.stream/wayback/20220611235909im_/https://answers.unity.com/themes/thub/images/avi.jpg)