Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by hypnoslave · Feb 20, 2011 at 07:20 AM · inputoptimizationupdatekeyboardoptimizing

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hypnoslave · Apr 04, 2011 at 06:49 PM 0
Share

Interesting, guys, Thank you both! I'll give you both a check-mark if i could. Ting!

avatar image
2
Best Answer

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).

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges