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 Laabu19 · Feb 25, 2017 at 08:24 AM · inputmousepositionupdate functionframes per second

User action too fast for Update()

I'm working on a game where you draw lines on the screen while the left mouse button is held. One of the objectives is to make sure when you hit anything as you're drawing, the line drawing ends. I'm using raycasting to detect what I hit, it works fine but if I move the mouse cursor too fast, the line passes through the objects on its way.

This was very confusing, so I decided to track the mouse positions on the console as I drew, I noticed that if I draw the line slowly, all the proper input get's recorded, if I draw too fast, it does not return all the input, instead, it just skips through most of the positions between the start and end points. I did some research and I found out that if your user input is faster than the Update() function, this would happen, some suggested FixedUpdate() with some tweaking in the project settings, I tried that but still no luck.

Any ideas on how to get around this?

Thank you...

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
0

Answer by hexagonius · Feb 25, 2017 at 09:09 AM

this is normal. the position is tracked each frame. depending on the performance this can be 200 times or only 5 times per second. the only reasonable way of doing this is measuring the distance in between points based on a minimum distance.
what you consider proper input is just a very small stepping, what about in between those points?
what I'm saying is there is an infinite number of positions you miss, it's just a question of how close you want them.

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
avatar image
0

Answer by Pengocat · Feb 25, 2017 at 09:18 AM

The lines you draw should perhaps include a ray or a calculation that checks if the line intersects with something and if it does then stop the drawing of the line. You can't force the Update loop to run at any particular rate. If you could then every game would be running at 1000 fps or more. It has to drop some information to keep up with the current state, but you can compensate by doing some calculations that take the lost information into consideration.

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

6 People are following this question.

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

Related Questions

Alternative for checking every frame if the mouse was used 1 Answer

How to check if a player click on a object: Android Mobile 1 Answer

Problemas con Input.GetKeyDown() 0 Answers

Get mousePosition more frequently than every frame? 0 Answers

Mouse position from new InputSystem is not correct and is not the same as Input.mousePosition 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