I’m trying to make a gui.box scale over “X” seconds (let’s say 3 seconds, but it’s going to vary).
Does anyone have any suggestions about how I’d go about doing this? It’s really doing my head in.
Essentially it’s a casting bar, I want the bar to always be a certain amount long (250 pixels), then scale down to 0 pixels over the ‘cast time’, which will just be an intiger.
One trick I’ve learned is that the GUI functions and their Rects work with float values. So say you have a variable that represents progress of some sort. You can Lerp it between 0.0 and 1.0, then in OnGUI you can do this
the 250, and 5 are the max and min widths of the bar - barwidth is the width of the bar which you plug into the ongui)
CurrentCastTime is the time you want it to take when lerping between the 250 and 5 (in this case it was 3 seconds)