Hello i currently am creating a trivia racing game, with this game i need a FUEL GAUGE preferably vertical on the right side of the screen. The Gauge would optimally start at 100, and everytime a question is answered correctly the gauge would gain 10 gas or something of that sort, and the gauge is constantly depleting forcing you to answer questions correctly to continue racing. Please help ! I can post the question script if need be ! Thanks
Eric posted pretty much what you are looking for on the forums already. You may need to modify the script some, make sure you check out the rest of the posts in the thread, i believe there is .unitypackage to download. Thread here.
Depending on how you want to deplete the counter (time passed, wrong answers etc) you will need a timer. This can be accomplished by
- counting time (Unity - Scripting API: Time.deltaTime)
- IEnumerators (Unity - Scripting API: MonoBehaviour.StartCoroutine)
the wrong answers is simply a subtraction.
Increasing the fuel with correct answers is a simple addition. ( for example: CurrentFuel += 10; )
Now the graphics would probably need a digital clock font and a GUIText object:
http://docs.unity3d.com/Documentation/Components/class-GuiText.html
So the system works as follow.
- You have a variable that stores the current fuel.
- You make a timer that decreases said variable using the timer mentioned.
- Correct answers add to this variable
- You update GUIText.text value using the CurrentFuel value.