The Jump Jam (Mobile) Tutorial uses the following code to restrict player.velocity.y after applying GRAVITY = 15.0 and with a Global variable var max_fall_velocity = 1000.0
if velocity.y > max_fall_velocity:
velocity.y = max_fall_velocity
If I try to print velocity.y in both cases it is restricted to 1000, but player.jump() only works with the code shown in the tutorial. Can someone explain why ?
print([velocity.y, clamp(velocity.y, gravity, max_fall_velocity)]) showed that clamp overwrites the jump velocity and sets it to the MIN of the clamp (GRAVITY) where as the If condition does not alter the MIN of velocity.y
so using the clamp would be the equivalent of the following if condition ?