Jump to content
  • Advertisement
DevBlazer

Some questions about fluid mechanics

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 this post


Link to post
Share on other sites
Advertisement

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, 🤡

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!