How could I create an atmosphere in a spaceship
Not downloaded yet
Crossposted from
The original post is not in the archive.
About this post
- Posted
- Archived
- Score
- 2 · 100% up
- Kind
- Image · crosspost
- ID
- mno01t
The original post is not in the archive.
3 comments
Is your game time based or room based? If it's tile based then you can implement a system that makes air go from high pressure to low pressure tiles, with a something like 8 pressure levels for each tile.
If it's a room based system, you'd want a room pressure and room volume (based on the size of the room) so that bigger rooms have more air.
Space tiles/rooms will always be 0% air, and the atmosphere will always want to go their if the system is implemented correctly
It's close to the "Oxygen not Included" game as I see.
Gas and liquids levels are simulated with tiles. Tiles have value how full they are, and update animations using these values. Tiles that close to doors lose oxygen first. If sum all values can get how much oxygen we have in the room.
Maybe I'm wrong but when played that game I had the impression it works that way.
There are lots of different answers to this question and which one is best for you depends on what level of physical accuracy you want and performance considerations.
The highest level of physical accuracy would be to directly use fluid dynamic equations (ie Navier-Stokes equations) to calculate how the gas actually would move. This is probably impossible to do in a game. I believe analytic solutions to the NS equations only exist in certain limited cases.
A lower level of accuracy (but still potentially very high accuracy) would be to do some kind of finite difference modeling to approximate the actual flow of gas in small regions. You essentially divide the room into a grid and take small time-steps. At each time step you calculate how gas flows from each cell of your grid to the neighboring cells depending on the differences in pressure. This is how most engineering applications deal with this kind of modelling.
But do you really need that much accuracy? What if you just give each room a gas value based on its size, and when two rooms become connected the gas between them equalizes instantly? When a room becomes connected to "outside" the gas could instantly equalize to zero.
If you don't want it to be instant, you could have a maximum rate that the gas in a room can change per frame.
If you want to add forces to objects during these changes in gas levels, just do it in a hacky unrealistic way that looks and feels convincing. Just apply some force to every object in the room toward the point connecting the room to whatever other room the gas is escaping to.
Quill18 made some kind of rudimentary oxygen-level thing in this tutorial: https://www.youtube.com/watch?v=qyvN-YolIdQ&list=PLbghT7MmckI4_VM5q3va043FgAwRim6yX&index=49 It has been a long time since I watched it, so I don't remember exactly how he approached it.