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 /
  • Help Room /
avatar image
0
Question by paragraph7 · Jun 22, 2016 at 11:35 AM · physics2dtouch controlstouchscreenfixedupdateupdate function

TouchInput in Update. Physics in FixedUpdate. Lag and Lost calls?

So I know that FixedUpdate() should be used for Physics and ever since I read that I've been writing my Jumps, Movements etc. in FixedUpdate(). But now as I completed a touch input script in Update(), I find a severe lag between the Input checks made in Update() and the resulting Physics calculations in FixedUpdate(). For example, I made some prints inside the calls and got this:

"Swipe at 5.344789" "Movement at 5.36" "Swipe at 7.440634" (Missing movement call here) "Swipe at 8.274659"

Not only was the Movement Physics 0.02s late, the next Movement was lost entirely. This would happen on occasion, with various lag in between. Well, I moved all the movement scripts to Update(), exactly after the Touch Inputs, and everything worked instantly, although I had to put some Time.deltaTime multipliers to the Physics to make them smooth.

Why is this? Am I doing something wrong in gathering touch inputs and changing boolean states in FixedUpdate upon those inputs? What I've usually seen other people do is exactly that, like:

 bool jump;
 
 void Update() {
     if (Input.touchCount > 0) {
         // do necessary touch things
         jump = true;
     }
 }
 
 void FixedUpdate() {
     if (jump) {
         // do Jump physics
         jump = false;
     }
 }

Is this a bad approach, or is the problem somewhere else?

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
0

Answer by WILEz1975 · Jul 23, 2017 at 04:12 AM

Is a good question.... No reply?

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

60 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

Related Questions

Touch Controls inaccurate after screen sleeping 0 Answers

How can convert keyboard controller to touchscreen(android .ios ...etc) 1 Answer

Rotate Player w/Touch Input Controls 0 Answers

WebGL and videoplayer set frame not working in Unity 2019.4.0f1 1 Answer

How can I change my player control method to use a touch screen ?? Pong-clone 2D 0 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