• 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
49
Question by Nicolaj Schweitz · Jan 15, 2010 at 09:04 AM · scriptingbasicscompilingmono-behaviourexecution-order

What is the general use of Awake(), Start(), Update(), FixedUpdate(), LateUpdate()?

Can you please provide me with some general usage examples of the following methods in the MonoBehaviour class.

For Initiating:

Awake()
Start()

  1. Why do we have two initiation methods?
  2. What are the differences?
  3. What are the best practices when using them?

For Updating:

Update()
FixedUpdate()
LateUpdate()

  1. Why three different update methods?
  2. What are the differences?
  3. ... and again some best practices?
Comment
Add comment · Show 1
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 Noob_Vulcan · Aug 12, 2015 at 02:00 PM 0
Share

If need more explanation you can refer to http://www.unityrealm.com/monobehaviour-unity-basic-tips/

7 Replies

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

Answer by runevision · Jan 15, 2010 at 09:29 AM

This really is something that is well covered in the scripting reference, so I'll just link to the descriptions:

  • Awake
  • Start

Quoting from the docs:

The difference between Awake and Start is that Start is only called if the script instance is enabled. This allows you to delay any initialization code, until it is really needed. Awake is always called before any Start functions. This allows you to order initialization of scripts.

  • Update
  • LateUpdate
  • FixedUpdate

LateUpdate is called after all Update functions have been called. This is useful to order script execution. For example a follow camera should always be implemented in LateUpdate because it tracks objects that might have moved inside Update.

Also note that LateUpdate is called after animations are applied - this means you can implement procedural animation in LateUpdate which modifies the pose sampled by the animation system.

FixedUpdate is called every fixed framerate frame, if the MonoBehaviour is enabled. FixedUpdate should be used instead of Update when dealing with Rigidbody. For example when adding a force to a rigidbody, you have to apply the force every fixed frame inside FixedUpdate instead of every frame inside Update.

I hope that helps. You can read more about overridable functions on the scripting reference page for MonoBehaviour.

You can also read here about the Update Order.

Comment
Add comment · Show 4 · 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 encadyma · May 12, 2014 at 03:29 AM 0
Share

I finally understand the difference. Thank you for putting it together so well in one post!

avatar image jedd.ahyoung · Jul 18, 2014 at 09:29 PM 2
Share

Update Order link has changed since the time of this writing. It is now here (http://docs.unity3d.com/$$anonymous$$anual/ExecutionOrder.html) and includes the initialization and render steps as well.

avatar image demented_hedgehog · Mar 20, 2015 at 12:26 AM 0
Share

Use the link above ... ^^ jedd's is the best answer. I can't vote it up enough times to get it to peoples attention :(

avatar image enoy · Aug 29, 2017 at 07:20 PM 0
Share

Thank you runevision for your help pointing the main differences between awake and start and it is good that jedd.ahyoung updated the link!

avatar image
44

Answer by yoyo · Jan 31, 2011 at 04:32 PM

Regarding Awake and Start, I treat Awake as "initialize me" and Start as "initialize my connections to others." You can't rely on the state of other objects during Awake, since they may not have Awoken themselves yet, so it's not safe to call their methods. Once you get to Start, all objects are Awake and can call each other.

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 IR Nifty · Apr 23, 2013 at 03:31 PM 2
Share

Very interesting concept. I'm glad I caught this now, before I ended up with a mass of pointless bugs later. Not repped enough to thumbs up, but I totally would.

avatar image Creator347 · Jul 23, 2013 at 07:00 AM 0
Share

I was thinking which one to use awake or start for initialization, you cleared the doubt. Thanks a lot.

avatar image
6

Answer by SisterKy · Jan 15, 2010 at 01:08 PM

Also I'd like to add this quickstart-overview form the forums
http://forum.unity3d.com/viewtopic.php?t=2719 ( also read the rest of the thread! )

These go some deeper about execution-order:

the Wiki-page http://www.unifycommunity.com/wiki/index.php?title=Event_Execution_Order

http://answers.unity3d.com/questions/1405/is-function-update-short-for-function-start-whiletrue
(example of co-routines fitting between Update and Late-Update as Mr. Ante described in the forum-post above)

http://answers.unity3d.com/questions/1254/is-invoke-just-a-short-version-for-yield-waitforseconds-functioncall
(executionorder of invoke vs. co-routine)

Greetz, Ky.

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
3

Answer by TriplePAF · Jan 15, 2010 at 10:51 AM

Here is an additional link from the Unity Manual

Peter.

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 theRiley · Sep 06, 2014 at 10:19 PM

if anyone else stumbles into this, all the info above was helpful, but I also liked the examples in this video

http://unity3d.com/learn/tutorials/modules/beginner/scripting/awake-and-start

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
  • 1
  • 2
  • ›

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

8 People are following this question.

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

Related Questions

function execution order 1 Answer

Difference of assigning a variable outside any function, in Awake or in Start? 3 Answers

'function Update' vs 'function Start {while(true)}'? 3 Answers

Question about Coroutines/Time 0 Answers

Will System.DateTime work on Android/iOS? 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