Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculating the Amount of Fluid
#1
Pregunta 
I'm doing a game where I carry water in a container. The amount of water remaining in the container is different in each section.

I want to give a percentage of how much water is left in this container. How am I going to do this?
Reply
#2
(04-03-2021, 03:53 PM)Oziko Wrote: I'm doing a game where I carry water in a container. The amount of water remaining in the container is different in each section.

I want to give a percentage of how much water is left in this container. How am I going to do this?

You can use a trigger collider that spans the entire volume of the container. Then use collision callbacks:
http://obi.virtualmethodstudio.com/tutor...sions.html

To count how many particles there are inside the container. Check the included FluidMaze sample scene, it uses this method to calculate the percentage of fluid that has reached the maze goal.
Reply
#3
(04-03-2021, 03:57 PM)josemendez Wrote: You can use a trigger collider that spans the entire volume of the container. Then use collision callbacks:
http://obi.virtualmethodstudio.com/tutor...sions.html

To count how many particles there are inside the container. Check the included FluidMaze sample scene, it uses this method to calculate the percentage of fluid that has reached the maze goal.

As a side note, the FluidMaze sample scene only counts the particles that already reached the goal, regardless whether said particle is still inside the goal or not. Of course you can modify it a bit to make it run every single frame and that way you will have an always up to date amount, but it comes at the cost of performance.

But most likely you don't have to check it every single frame. You can pinpoint specifics points in you game when you need to do this and only do it then.
Reply