I tried to make a bar that desreases automatically with a current time from 100% to 0%. The bar can increase with 50% if the player takes an object. And if the bar is 0%, you have to go to alternative scene. Someone who can help me out with. I’m really confused now. I’m working with JS.
Thanks in advance.
1 Answer
1
All you need to to add a timer:
#pragma strict
var totalTime = 5.0;
var remainingTime = 5.0;
var Bar:Texture2D;
var BarWidth:float=400;
var BarHeight:float=200;
function Update() {
if (remainingTime > 0.0)
remainingTime -= Time.deltaTime;
}
function OnGUI(){
GUI.DrawTexture(Rect( (Screen.width - BarWidth)*0.5,(Screen.height - BarHeight)*0.5, BarWidth* remainingTime/totalTime, BarHeight), Bar);
}