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.
asked Feb 20 '11 at 07:20 AM
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.
answered Apr 04 '11 at 06:39 PM
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).
answered Feb 20 '11 at 09:00 AM