<< Code Omitted >>
It does work when you press space to jump but when you hold space he wont stop until you let go. How do i stop this?
You need to add another condition to jump -- mainly, is the actor standing on the ground (or on top of an object). Easiest way to check this is to apply gravity and fall first; then, check for obstacles. If the vertical speed is positive and an obstacle is found, than the on ground state is met and you can then check for the jump key. My Jump and Run Demo w/Moving Platform illustrates how this is done.