I just finished the space ship/shooter tutorial, and i added a secondary fire that clears the screen, it has a delay time of eight seconds inbetween shots and i wanted to make a progress bar that shows when the next shot can be fired, ive already coded in a progress bar but i cant get the timing right
This is thew code that i have / am using
Edit: wfiretime and nextwfire are simply the timings fro the secondary firing, the same as the primary if youve seen the tutorial.
public float barDisplay;
public Vector2 pos = new Vector2(20,40);
public Vector2 size = new Vector2(60,20);
public Texture2D emptyTex;
public Texture2D fullTex;
void OnGUI() {
GUI.BeginGroup (new Rect (pos.x, pos.y, size.x, size.y));
GUI.Box (new Rect (0, 0, size.x, size.y), emptyTex);
GUI.BeginGroup (new Rect (0, 0, size.x * barDisplay, size.y));
GUI.Box (new Rect (0, 0, size.x, size.y), fullTex);
GUI.EndGroup ();
GUI.EndGroup ();
}
void Update()
{
barDisplay = (Time.time - wfiretime) / nextwfire;
}