Collection Bar that decreases

I’m trying to make a collection bar that slowly decreases over time, think of it like a fuel tank, if an item isn’t collected in a long time then the tank can run out and the game is over. I’m using the slider UI for it but I don’t think I’m properly using it, so I was wondering if anyone could help me with this along with a baseline of the programming, it would be immensely helpful.

That’s not a thing.

A fuel tank that runs out or a timer that runs out are all the same thing.

There are literally MILLIONs of Youtube tutorials out there. Start there.

Here’s the essential parts that will exist in 100% of all implementations of this:

  • a variable to store the quantity (such as float fuel;)
  • code to fill it: at start, at refueling (such as fuel = FuelMax;)
  • code to remove fuel from it (such as fuel -= FuelPerFrame;)
  • code to display it in a bar (such as uiImage.filled = fuel / FuelMax;)
  • code to decide it’s over (such as if (fuel <= 0) { GameOver(); })

Get busy, you won’t learn gamedev here in the forum.

You will do it one step at a time in Unity, like this guy:

Imphenzia: How Did I Learn To Make Games:

Stop making excuses!

1 Like