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
1
Question by Yisreal · Feb 19, 2010 at 12:58 PM · mouseupdatetimeeventfixedupdate

Action on mouse button up

My script is supposed to deactivate a variable every time the left mouse button goes up. For some reason, my script sometimes 'misses' running that part of the script when i let go of the left mouse button, and some times it works. I had it print a counter every time it ran that part of the script to be certain.

I have the script in the Update() function and have even tried the FixedUpdate().

In my game it is integral that the player have full control of the scene by holding down and letting go the left mouse button.

How can I write the script well enough to be certain that every time the left mouse button is held down and at a decided time let go that unity will not miss an event?

Thanks a Ton!

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 Eric5h5 · Feb 19, 2010 at 02:22 PM

Definitely don't use FixedUpdate, because it doesn't necessarily run every frame, and can miss events if they happen during a frame when FixedUpdate is not running. I've never seen an event missed if it's checked in Update.

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 cregox · Feb 19, 2010 at 04:28 PM 0
Share
  • I'm not even sure what FixedUpdate is for. From the description it says it's for physic interactions. In practice, I'm guessing it should be used just for NPC's and non-critical elements for saving processor cycles.

avatar image Eric5h5 · Feb 19, 2010 at 05:46 PM 0
Share

No, FixedUpdate is only for physics interactions, such as applying AddForce or suchlike. It should not be used for non-physics code, because while it might save CPU cycles when the framerate is high, it will use more CPU cycles when the framerate is low (below the fixed framerate), which is exactly the opposite of what you want. For code which should only run occasionally, use InvokeRepeating or other methods.

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

Frame dependant game. Using update vs fixed update. 3 Answers

How often does the internal physics calculation get called? 1 Answer

Is there an equivalent of Time.frameCount for physics updates? 1 Answer

Slow motion all but one - yet another round, hopefully the last 6 Answers

Fixed timestep... 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