Why wouldn’t using clamp()
work here ?
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
I tried using clamp as follows
velocity.y = clamp(velocity.y, GRAVITY, 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 ?