If you want to make the player jump, think about what happens what actually happens when you jump. A force gets added at the moment you push yourself away from the ground, but no extra force gets added while you're in the air. Instead, because of gravity, you'll come down again. Make sure you use both AddForce (only once) and set the gravity in the rigidbody inspector
That's all you need for a jumping script. Also check out the Unity2D tutorial with the bean-guy.
↧