- Home /
Trying to remember a good function design for moving a bar back and forth?
I already have my bars setup in the GUI to expand and contract a progress bar based on a solid value. What I'm trying to get is some function that would cause the bar to gradually grow or shrink to it's new value when changed.
if(energyDisplayed<energyCurrent){
energyDisplayed=Time.time*25f;
}
GUI.Box(new Rect(EnergyBarRect.x,EnergyBarRect.y,EnergyBarRect.width*(energyDisplayed/energyTotal),EnergyBarRect.height),(int)energyDisplayed+"/"+energyTotal,skins.customStyles[9]);
Answer by IndieScapeGames · Aug 03, 2012 at 09:50 PM
I think you may be close, could you possibly share a little bit more of your code.
Right now, it looks like your bar will grow width wise with time. I will edit this with a correct fix when I'm able to see more.
That is actually all that I have for it right now. Like I said, having a brain-dead moment. I really just need to get it to count back
I discovered part of my problem: Use energyDisplayed+=Time.deltaTime*25f;
Ah, that's right because it's Time.deltaTime is a float.
Good catch!