hi … i have made my power up part, when i collide with my power up object magnet, it starts collecting coins(like magnet catcher) and after 12 seconds it backs to normal. what i am looking for is just to show a power up bar which like health bar which show for the time we assign, like 12 seconds and after that disappear. … like in subway surfer,like this or minnion rush circle power up bar … i have searched but i am not understanding it very well … i have tried to applied this one … but its not working like i want
… kindly help me please … i ll be more than glade …
… its driving me crazy …
#pragma strict
var barDisplay : float = 0;
internal var pos : Vector2 = new Vector2(20,40);
internal var size : Vector2 = new Vector2(20,50);
var EmptyS: GUIStyle;
var FullS: GUIStyle;
var progressBarEmpty : Texture2D;
var progressBarFull : Texture2D;
var progressBar : boolean = false;
function OnGUI()
{
if (progressBar==true)
{
// draw the background:
GUI.BeginGroup (new Rect (pos.x, pos.y, size.x, size.y));
GUI.Box (Rect (0,0, size.x, size.y),progressBarEmpty);
// draw the filled-in part:
GUI.BeginGroup (new Rect (0, 0, size.x * barDisplay, size.y));
GUI.Box (Rect (0,0, size.x, size.y),progressBarFull);
GUI.EndGroup ();
GUI.EndGroup ();
}
}
function Update()
{
// for this example, the bar display is linked to the current time,
// however you would set this value based on your desired display
// eg, the loading progress, the player's health, or whatever.
barDisplay = 1 -Time.time* 0.05;
}