Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by DrZarqawi · Aug 10, 2016 at 03:11 PM · c#spacesimulationairflow

Air volume and flow between rooms like FTL

Hi :) I'm working on a space based tycoon game and as a part of that air management is a feature. But i can't figure out how to simulate air flow and pressure between the rooms i create.

in my prototype i have a central (green) square being the Oxygene provider, and around that i can place new (white) squares. the idea is that when a new white square is connected to the green square air pressure should drop and air should flow to the white square slowly turning it blue based on the current air volume and pressure.

Edit: Also each room has an Air consumption rate, so if air generation can't keep up the rooms should slowly run out of air. screenshot:

it's easy enough for me to figure out with only two rooms, but the moment that number increases im at loss :/

thanks in advance :)

air-room-screencap.jpg (188.4 kB)
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DrZarqawi · Aug 10, 2016 at 01:36 PM 0
Share

what im basically looking for is some sort of fluid simulation. but all the other tutorials and answers about it is more focused on getting the movement of the fluid right which is not really relevant for me, since my fluid is never seen and only simulated through variables.

avatar image DrZarqawi · Aug 12, 2016 at 10:45 AM 0
Share

No one?? I'm not asking you to write my code, just to be pointed in the right direction :)

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by NerdClown · Aug 12, 2016 at 11:04 AM

Did something similar in a project a few years ago. Fire fighting kind of game, where the oxygen of a room would be important for both fire and survival.

My solution was definitely not a simulation, but it gave an okay feeling and a bunch of variables that the designer could tweak. Here's a really rough description of my solution, in case it'll help:

It involved a controller that would know all the rooms (they registered on spawn). This controller would call each room a few times per second. It would take three steps (which wouldn't need to be carried out in the same frame).

First it'd apply intake/usage of oxygen within each of the rooms.

Each room knew its neighbors and how much air flow could happen between them (door open/closed and such). So for the second step, the controller would then ask each room to see how much air would flow to the neighbors. These numbers were stored (oxygen gained/lost) for each room.

In step three, the controller would go over all the room again, and ask them to apply oxygen gained/lost. The reason for splitting step two and three up was to make sure that the order in which the rooms registered on the controller wouldn't matter when progressing this.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DrZarqawi · Aug 12, 2016 at 12:37 PM 0
Share

In my game the only way to close of airflow would be to disconnect a section from the provider, but that might be similar to a Open/closed door :)

I was split between making one controller object or giving each room an Airflow script and initially opted for the latter, but i can see how i could organize it better in one script :)

where i am really stuck is how i would go about calculating the intake/output.

right now im thinking something based on pressure, like:

 Pressure = Output  - OxygeneLevel / intake

and then calculate how much would be needed to take in pr. sec or how much would be needed to put out pr. sec. the problem lies in, in order to calculate pressure i need output and intake, which i need pressure to calculate :/

thanks for the reply :) you should have put it as answer :)

avatar image NerdClown DrZarqawi · Aug 12, 2016 at 12:42 PM 0
Share

Thanks, converted to answer :)

I did something like

 (oxygenRoomA - oxygenRoomB) * timeSinceLastUpdate * oxygenFlowPerSecond

With airFlowPerSecond being between 0 and 1.

But my task was a bit different from yours ... everything had the same pressure, but the concentration of oxygen in the air would rise and fall.

avatar image DrZarqawi NerdClown · Aug 12, 2016 at 12:56 PM 0
Share

Thanks :) I see the difference :) but combining what you made with my idea with pressure i now think somethink like: the provider room always has a constant intake, so calculating its pressure based on the adjecent rooms Oxygene level should be possible, and then calculate how much spare oxygene it has. Set that as the output devided by rooms connected to the provider. And then calculate the new rooms pressure based on intake and connected rooms oxygene level.

The most important thing for my script is that the air allways flows to where the pressure is lowest :)

avatar image
0

Answer by YoungDeveloper · Aug 12, 2016 at 10:54 AM

This can have many solutions, easy solutions, which are not as precise and extremely complicated ones. First thing what comes to my mind is why not use small rigidbodies as air particles? Create them and apply slight force, they will fly into your corridors and "look like" air. You could apply smart mapping or just particle texture on those rigidbody points later on. Each of those particles could also contain some component which slightly moves them in random direction (or depending on some singleton manager) to ensure they will never actually stop.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DrZarqawi · Aug 12, 2016 at 12:29 PM 0
Share

I think you misunderstood my question :) I don't need to see the actual air :) All i want is to figure out a way based on adjecent rooms Oxygene level to tweak my current rooms Oxygene level variable.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Pipe flow simulation shader 1 Answer

how to draw trajectory of rocket for faux gravity in unity???? 0 Answers

RigidBody.AddRelativeTorque // Input.GetButtonDown issues 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges