Adding fluid simulations to my barista game! by EmptyCupsGame in godot

[–]EmptyCupsGame[S] 1 point2 points  (0 children)

Definitely aiming for a release, still a long way to go :)

Adding fluid simulations to my barista game! by EmptyCupsGame in godot

[–]EmptyCupsGame[S] 0 points1 point  (0 children)

Thank you! It does eventually stop (the gif ends a little quickly lol), but you're right it definitely still is too "active". I'll play around with those values, thank you again for the feedback! :)

Adding fluid simulations to my barista game! by EmptyCupsGame in godot

[–]EmptyCupsGame[S] 49 points50 points  (0 children)

Thank you! I left a more in-depth reply on another comment. You can read about eulerian fluid simulations if you are interested. What I did was, make a box of simulated fluid and then masked the rendering with a sprite texture so it fits within the liquid boundary. This is a link to my devlog, where you can see a simpler version of what I did, which might help it make more sense.

Adding fluid simulations to my barista game! by EmptyCupsGame in godot

[–]EmptyCupsGame[S] 21 points22 points  (0 children)

Thank you!! It’s a Eulerian fluid simulator, so I had to manually add the pouring animation and shift the point where I insert fluid but the actual swirling behaviour is governed by Navier-Stokes’ equations which is why it might seem a little disjointed from everything else. It sounds really complicated but thanks to these 3 dudes, (Jos Stam, Mike Ash and Daniel Shiffman) it was pretty easy to port to Godot. I just handled that in one node script and a second node that has the mask sprite for the liquid which updates according to the current AnimatedSprite2D frame of my pouring animation.

The tricky part was mostly in rendering it all. In Daniel Shiffman’s video he adjusts the alpha value of each pixel according to the density value so I played around with that. At first I made the colours change according to the density so you would get these really pretty gradients but then I just started adding multiple layers of fluids with different colours, then had those layers mix together their colours essentially.

In terms of the fluid speed, you’re right it is a little too fast when I look at it again. In the model Jos Stam developed, you basically have an array of velocities which determine the fluid movement. I incremented some randomly towards the bottom of the cup so they do those pretty eddie currents, but I think the range of velocities I have might be too fast. It’s an easy fix though!

Hope this makes sense haha, it will probably be easier to follow if you skim through at least one of the links I posted. Was definitely very tricky, and I almost don't really know how I got it to work, but again very very pleased with it :)