- Home /
No input from keys for specific amount of seconds?
Right now I am programming my FPS game and I wanted it so that if the player has not pressed any keys for 30 seconds, a waiting/idle animation plays where the character looks at his gun. I've been searching on the forums for a while but I haven't been able to find anything on how to check if there has been no input for a certain amount of seconds. Does anyone know?
Comment
Answer by robertbu · Feb 09, 2014 at 09:07 PM
This is something you have to code yourself. A timestamp model would be simple. At the top of the file:
var timestamp = 30.0;
Then in Update() if any key is pressed do:
timestamp = Time.time + 30.0;
Also in Update():
if (Time.time >= timestamp) {
Debug.Log("No key as been pressed for 30 seconds");
}
Your answer
Follow this Question
Related Questions
How to make realistic 2D balloon physics 0 Answers
Input.GetKey 1 Answer
Play complete animation 1 Answer
Benefits of root motion 1 Answer
Animation Layering 2 Answers