Isn't there a general parameter that I can give Unity to have it perform a specific task when a specific button has been pressed?
I understand that with the if-Statements that we call every frame, we are telling Unity to check whether a specific button has been pressed or not and what to do if said button has been pressed. But that seems rather performance-draining on larger games where there may be several hundred if-Statements that need to be checked each frame.
So can I not simply state that instead of checking whether a button has been pressed or not, Unity should simply not do anything until the button press has been made and then perform the associated task?
Because I don't see that going well regarding performance on a game that runs 30 frames per second or more and Unity has to check a hundred if-Statements 30 times a second.
Not to mention with some type of games like competitive shooters, players fight for every millisecond less delay. So in those cases would it even be enough to call an if-Statement once every frame or would you have to double it to get an almost 0-delay-reaction which in return would also create twice the load on performance.
Sorry for the long description
As far as I'm aware there is no better or even different way of checking for input. I don't know if this will be changed in the future, but it's not a performance drain by any means. Yes you should use Update only as needed and input is one of those things. If you're using GetComponent or calculating some complex math in the Update method then that's where you'd start to see performance issues.
You could always use something like a Coroutine that checks less often, maybe once every .05 seconds, but then you may lose some of the precision. So there's always a trade up. The current way is still used because it's simple and performant.
Oh, I see! No, I think the check-per-frame-rate is fine, I just assumed that it must be performance-draining.
I understand, thank you very much!
I'm currently going through almost all of your courses. They are really good and help me a lot atm. Keep it up, mate! :)
Thanks glad I could help! Feel free to post any questions you have and I'll do my best to answer.