I am trying to make my character jump only once, but it can jump as many times as the “W” key is pressed. Another problem is that it can just stick to a wall, basically meaning it can easily climb walls when it is not supposed to. Here is my code, any help would be greatly appreciated: public float moveSpeed;
public float jumpHeight;
Rigidbody2D character;
void Start()
{
character = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
if (Input.GetKey(KeyCode.S))
{
character.velocity = Vector3.down * moveSpeed;
}
else if (Input.GetKey(KeyCode.W))
{
character.velocity = Vector3.up * jumpHeight;
}
else if (Input.GetKey(KeyCode.D))
{
character.velocity = Vector2.right * moveSpeed;
}
else if (Input.GetKey(KeyCode.A))
{
character.velocity = Vector3.left * moveSpeed;
}
}