- Home /
Question by
Ryoshi217 · Jul 30, 2012 at 06:50 AM ·
c#inputgetkeydown
Why is my Input.GetKeyDown not working??
hi i am new on unity and need some help my Input.GetKeyDown is not working , i have other Input.GetKeyDown statments in my game but this one is not working please could you help me thanks.
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown ("F")) {
Debug.Log ("click");
rigidbody.AddRelativeForce(0,0,10);
}
}
}
Comment
Ins$$anonymous$$d of saying 10 try 999999 or something.
Best Answer
Answer by Eric5h5 · Jul 30, 2012 at 07:24 AM
You would get an error message telling you there is no "F". Use "f", or better yet, KeyCode.F.
Answer by Anne_Marije · Jul 30, 2012 at 08:33 AM
Maybe type it as
if (Input.GetKeyDown ("f"))
You can also use the keycode enum, which is how I tend to do it
if (Input.GetKeyDown (KeyCode.F))