Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by qmzpalqmzpal · Dec 06, 2017 at 07:53 AM · inputupdatetime.deltatimeinputmanager

Exactly when are inputs updated?

Let's say we get GetAxis and move player in Update function. What we would do is check input and than move some distance based on Time.deltaTime, so time between this update and last update, since we base on deltaTime to calculate distance travelled it should mean that input was received during last update right? I mean we just say that since user clicked "left" 0.2 seconds ago it means that player would travel 0.2 *speed. But as far as I see Inputs are triggered just before Update https://docs.unity3d.com/Manual/ExecutionOrder.html. Does this mean that actually we don't correctly calculate distance traveled? I understand that even if that's true we won't notice any difference.

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

1 Reply

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

Answer by NorthStar79 · Dec 06, 2017 at 08:06 AM

Inputs get updated right before Update() usually this does not cause any reasonable time shift but yes there will be an input lag between real key press time and Update() method. This does not mean that you are calculating distance travelled false, just means you can not react input changes very precisely. but as you said too, this won't create any change unless you are using Unity to simulating an interstellar probe's trajectory which is moving at relativistic speeds :)

Comment
Add comment · Show 2 · 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 qmzpalqmzpal · Dec 06, 2017 at 08:12 AM 0
Share

Not only lag between real key press time and update. Let's say let's say we click "left" exactly at the time inputs are calculated and now in Update we see that user clicked "left" button, time between input check and update is e.g 0.001 and deltatime is 0.2, so player should have traveled just 0.001 times speed but now we would make it travel 0.2 times speed right? Just trying to understand it well :)

avatar image NorthStar79 qmzpalqmzpal · Dec 06, 2017 at 08:53 AM 1
Share

yeap that's the exact situation would have occurred in that scenario. and you can decrease its Error by using something like this:

    if(Input.Get$$anonymous$$ouseButtonDown(0) == false && Input.Get$$anonymous$$ouseButton(0))

this will increase the Input lag but also helps correctly calculate distance traveled.

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

85 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Update() in non-component script? 3 Answers

Supplying Input from Update To FixedUpdate 1 Answer

Is there a way to modify Input Manager so that an ax is be able simulate an input from code? 0 Answers

how to make a configurable input 1 Answer

InputManager doesn't detect gamepad numbers correctly 1 Answer


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