- Home /
Reading input outside of Update or some other ticking system
Hey, I'm working on removing as much as possible from Update(), or anything else that ticks like a mo-fo. I wondered if it was possible to read keyboard input that isn't dependent on checking EVERY FRAME if(Input.GetKeyDown) or what ever.
I'm still a n00b, but it seems like that's SUCH a sloppy way to do it. is there some sort of keypress event that I can listen for instead? if not in unity, perhaps in .Net?
I have decided that ticking is for suckers.
Answer by Parthon · Apr 04, 2011 at 06:39 PM
Ticking might seem like it's for suckers at first, but you have to remember that every frame of your game the computer is pumping that scene data to your GPU, then getting it to transform every polygon and paint it on the screen. There's millions of cycles being used to do the same thing over and over 60 times a second.
An if statement in an update function is nothing compared to everything else that's going on.
The alternative is what Eric5h5 said: callbacks on keypress. And like Eric said, callbacks aren't available in Unity. You could wrap the input class in something that emulates callbacks, but you'd still need to put it in a ticker function somewhere.
The input loop is still being used even after decades of game development because it's fast and simple.
Interesting, guys, Thank you both! I'll give you both a check-mark if i could. Ting!
Answer by Eric5h5 · Feb 20, 2011 at 09:00 AM
There aren't any input callbacks unfortunately. You have to check every frame (or at least every frame that you're expecting that input can occur).
Your answer
Follow this Question
Related Questions
Keyboard Input Question 1 Answer
iOS keyboard okay button 0 Answers
Input.GetKeyDown doesn't work with several keys 1 Answer
iOS keyboard - adding and removing characters in a string on the fly 0 Answers
Input update interval fine tuning 2 Answers