- Home /
issue making a Power Bar go back down
I have a power meter that is used to hit a ball. My issue is that when the meter fills up I need the bar to reverse or go back down(although it's a horizontal bar). I posted the part of code to fill the power meter which works fine and the ball is hit based on where the bar is, just need to know if there is a way to reverse it. I originally tried to use Mathf.PingPong for this, which worked, but I couldn't get it to not run continuously. Any help would be really appreciated.
function OnGUI(){
speed = Time.time * 1.1;
GUI.DrawTexture(Rect(Screen.width/2 - 250, Screen.height/2 + 300, size.x * Mathf.Clamp01(speed), 40), fill);
Answer by Kiwasi · Jul 18, 2014 at 11:32 PM
Pseudo code as follows:
bool goingUp = true;
if (goingUp) {
// Run your code to make it bigger here
if(//bool check to see if at max size){
goingUp = false
}
} else {
// Run your code to make it smaller here
if(//bool check to see if at min size){
goingUp = true
}
}
Your answer
Follow this Question
Related Questions
How much is a meter in Unity? 3 Answers
Calculating player distance meter? C# Unity2D 1 Answer
Units of measurement in Unity 2 Answers
Possibility to draw objects with real world measurements? 1 Answer
Pixel-to-meter camera 1 Answer