I just wanted to fact check myself on a scenario where the player may be locked out of input.
With this example, there is a chance that the player's input will not be received if they happen to press the button during WaitForSeconds(), correct?
private IEnumerator CheckForButton()
{
// Check for player input at the beginning of the method
if (GameEngine.Instance.InputController.playerActions.Menu.Select.WasPressedThisFrame())
{
// do stuff
yield break;
}
// Is the player is locked out of input here?
yield return NewWaitForSeconds(2f)
}
To avoid that, would using a loop as a timer and checking for player input like this be a more correct way?
private IEnumerator CheckForButton
{
// Check for input at the beginning of the method
if (GameEngine.Instance.InputController.playerActions.Menu.Select.WasPressedThisFrame())
{
// do stuff
}
float t = 0;
float targetTime = 2f;
// Also check for input while the timer counts down
while(t < targetTime)
{
if (GameEngine.Instance.InputController.playerActions.Menu.Select.WasPressedThisFrame())
{
// do stuff
yield break;
}
t += Time.deltaTime;
yield return null;
}
}
To be more concise, will the player be locked out of input if they press a button during WaitForSeconds()? Thanks!