FixedUpdate and Input.GetKeyDown

Hi,

When I use Input.GetKeyDown(KeyCode) inside the FixedUpdate it seems that the key is not always triggerd. So when I would push 0 like in the code below it sometimes wouldn’t print the time whenever the key is pressed.
Is this because of the FixedUpdate or?

public void FixedUpdate()
{
  if (Input.GetKeyDown(KeyCode.Alpha0))
    Debug.Log(Time.time); 
}

GetKeyDown is only true for the one frame in which it occurs. FixedUpdate may or may not run during that frame. So, never use GetKeyDown (or any of the other similar Down and Up input options) in FixedUpdate.

–Eric

3 Likes

Ah okay, thanks for the quick response.