I have a error in a simple script
using UnityEngine; using System.Collections;
public class PlayerController : MonoBehaviour {
public float JumpForce = 100f;
void Start () {
}
void Update () {
if( Input.GetKeyDown( KeyCode.Space ) ) {
GetComponent<Rigidbody2D>().AddForce (new Vector2 (0, JumpForce));
}
}
}
when I press Space the Character simply doesn't do anything, but when I change GetKeyDown for GetKey it works, but I want to do it with GetKeyDown. Please Help!!!!! It's a simple script!!! C#
Have you tried increasing JumpForce? The reason it works when you use Get$$anonymous$$ey() but not Get$$anonymous$$eyDown() is because Get$$anonymous$$ey() will apply the force for as long as the key is held down, but Get$$anonymous$$eyDown() only applies it once.
Your answer
Follow this Question
Related Questions
continue something if a key is still pressed down? 1 Answer
How do I redeem my serial key from the old Unity 5? 0 Answers
Input.GetKeyUp wont work! 1 Answer
Specific key combination not working 0 Answers
Checking if any key is up? 3 Answers