Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
19
Question by Ziad · Aug 11, 2017 at 07:32 AM · updatefixedupdatelateupdate

What is the difference between Update() , LateUpdate() , FixedUpdate(), and when i should use them

Update() , LateUpdate() and FixedUpdate()


what is the difference between these and when i should use one of them and is it wrong to use Update() all the time?

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

3 Replies

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

Answer by Meltdown · Aug 05, 2011 at 05:10 AM

Check out this link on Update Order

Comment
Add comment · Show 7 · 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 Ziad · Aug 05, 2011 at 05:16 AM 0
Share

this is a good answer :D

avatar image Ziad · Aug 05, 2011 at 05:18 AM 0
Share

but.... can i have example about when i should use one of them :)

avatar image Meltdown · Aug 05, 2011 at 05:30 AM 2
Share

Generally, you will use Update for most operations. Such as changing transforms, or rotating items. FixedUpdate is usually used when you are calculating physics, such as applying forces to a rigidbody. i.e rigidbody.AddForce() etc. Anything that does calculations on the physcs side of things is usually used in FixedUpdate. In most other cases you will use Update().

avatar image Ziad · Aug 05, 2011 at 06:02 AM 0
Share

realy thanks dude :)

avatar image aldonaletto · Sep 30, 2012 at 08:25 PM 1
Share

I suppose this page was replaced by this one: http://docs.unity3d.com/Documentation/$$anonymous$$anual/ExecutionOrder.html

Show more comments
avatar image
15

Answer by GizmoKaracho · Aug 30, 2017 at 10:13 AM

  • Update() is called on every Frame, regardless of time passed since last frame
    • Good for Movement, InputControl etc. (most of the time you'll use Update)

    • Usually you will use Time.DeltaTime to take passed time into account (e.g. for GameObject Translations)

  • LateUpdate() is called after all Update() methods are processed
    • So e.g. for the camera that follows your character it's good to Update after it has moved

  • FixedUpdate() is called by the physics engine in fixed intervals (that can be set in the Options)

    • This is basically good for all Physics related functions (trigger, collisions etc.)

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 mdforbes500 · Aug 11, 2017 at 06:48 AM

Don't forget, @Ziad , that if you are performing camera scripting its best to put it in LateUpdate(). That way the movement calculations have already been done.

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 jessejarvis · Aug 30, 2017 at 12:21 AM 0
Share

I have in a LateUpdate function:

 if(!thisVariable)
      thisVariable = GetComponent<Component>();

Originally I had it in a Start() function but sometimes it wasn't setting itself which is why I set it here.

Is that okay for performance?

avatar image aldonaletto jessejarvis · Sep 02, 2017 at 01:44 AM 0
Share

Since thisVariable is initialized only once (that's the so-called "lazy initialization"), the impact on the performance is negligible - just an if instruction that evaluates false every frame but the first one.

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

9 People are following this question.

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

Related Questions

How can I make my cursor to follow more faster? (there's too much delay) 0 Answers

Only Disable One Update on a Script 1 Answer

Score, FixedUpdate and Update 0 Answers

How to handle FixedUpdate() and Input 0 Answers

Addforce in fixedupate 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