Recommended Posts

Hi all, I am currently playing around with making a 2D underwater survival game (pet project, not too serious) but I need someone I can sit with for like an hour or so, to help me flesh out some reasonable mechanics for the behavior of liquids and gases in relation to gravity, pressure, etc. (Sorry guys I totally failed science class and have no intention of studying it now).  There obviously has to be a balance between what I'm willing to code for and realism and then assistance with understanding some mechanics and how their formulas, etc would work.

Some additional info, I am making the game in javascript (web browser) and dont plan on using any physics related engines or libraries.  Also my first interests (as a starting point) for development lie in managing water vs oxygen vs immobile material in terms of gravity, weight, flow and pressure, both individually and against each other.  The game will naturally use a basic 2D block/grid system similar to what you would see in a game like oxygen not included.

If a voice chat not going to be so practical, then here are some of my starting questions:

Water has weight and is therefore pulled down by gravity, I know this.  I have also heard that water does not compress well, so I probably don't have to worry about deeper water having a higher density due to large amounts of water weight above it.  So assuming some constant or formula for gravity and water weight, if you have one tile filled with water, and nothing underneath it, it all falls straight down (not caring much about atmospheric interference).  But if you have solid mass underneath, then the water should probably fill tiles to the sides instead.  Im guessing a good way of doing this will be to multiply your chosen flow rate by the difference between the fuller tile and the more empty tile or something like that in order to calculate change over time?

There should probably also be something else at play here, as the liquid tile falling straight down would be very fast surely vs the 'flowing' into a neighboring tile or am I wrong?

Another consideration is how do you handle the concept whereby I believe the water would flow downwards (gravity) first before attempting to flow to neighboring tiles (or am I just being naive here)?

Also does gas or high pressure gas have any noticeable effect on any of the 'flow rates'?

Share on other sites

Water itself as a tile in air will fall like solid object.

Pressure with obstacles moving through medium, if something goes down theres a buoyancy force that acts up and gravity that acts down, not to mention medium flow (both air, water thats why i call it medium)

Air in water forms bubbles due to pressure around and thats what makes it go up (not mentioning weight).

With deeper water, water is deeper( bigger pressure acts on it) only when theres a blocker underneath it and theres another medium that acts on it) so i think when a water falls from a cliff it should have somewhat constant density,

For tile movement when you hit an obstacle and its only a one tile water 'could split into two parts) for simplification you could just check where it wants to go (which tile it would go without collision) and lerp between empty cellls that will receive water, 🤡

Create an account

Register a new account

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 14
• 30
• 9
• 16
• 12