Hi again friends,
I got a golf game where the power of the shot is equal to the distance between the mouse position and the ball position (with limitations, obviously).
Now, the bar, for example, can be 300px long but I want to show a number with the percentage of the power.
I'm horrible at maths xD
Develop games in your browser. Powerful, performant & highly capable.
Bar.MaxLength (300 px in your example)
Bar.CurLength (the current length, max, 300 px, min 0 px, anything within those two values)
(Bar.CurLength / Bar.MaxLength) * 100
Thank you soooooooooo much. Works like a charm.
If you want however an indicator not starting from 0 (for exemple, if your bar min lenght would be 10)
You could use unlerp(minlenght, maxlenght, curlenght)*100 to get the percentage