private void Update()
{
if(Input.GetKeyDown(KeyCode.UpArrow))
{
if(canJump == true)
{
rigidbody2d.AddForce(new Vector2(1, 500));
canJump = false;
}
}
}
/*
- If the player has collided with the ground, set the canJump flag so that
- the player can trigger another jump.
*/
private void OnCollisionEnter2D(Collision2D other)
{
canJump = true;
}
}