Infinite Jumping - (Javascript 2D Game)

Hi. I created a JavaScript to move player. I have problem with jumping. When I click space my sprite is jumping, of course, but I can jump multiply and player is “flying”.

#pragma strict

var hp : int = 100;
var speed : int = 5;
var jumpSpeed : float = 10;

function Start () {


function Update () {

		transform.Translate(Vector3(Input.GetAxis("Horizontal") * speed * Time.deltaTime, 0, 0));

	function FixedUpdate () {
		if (Input.GetButtonDown ("Jump")) {
			rigidbody2D.velocity = Vector2(0,10);

Sorry for every mistake. My english isn’t good.

You need a variable to signify when you’re allowed to jump, otherwise you can jump all the time. You then also need to reset this variable when certain conditions have been met, e.g. your character has touched the ground. I highly recommend watching the 2D Character Controllers live training video, it addresses these concerns as well as others you’ll run into: