• 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
2
Question by Alamaurie · Nov 18, 2015 at 10:38 PM · physicsexecution order

WaitForFixedUpdate Execution Order incorrect?

I have this script:

 [RequireComponent(typeof(BoxCollider2D))]
 public class ExecutionOrder : MonoBehaviour {
     public bool Triggered = false;
     void FixedUpdate () {
         if (Triggered)
             Debug.Log("Fixed Update Here");
     }
 
     void OnTriggerEnter2D(Collider2D other) {
         Triggered = true;
         Debug.Log("1");
         StartCoroutine(DoSomething());
     }
 
     IEnumerator DoSomething() {
         Debug.Log("2");
         yield return new WaitForFixedUpdate();
         Debug.Log("3");
         Triggered = false;
     }
 }

When an object runs through the trigger, I get the following in the log:

"1"
"2"
"3"

There is a distinct lack of the "Fixed Update Here" output.

Now, I suppose that it can be caused by the physics callbacks being run before the Coroutine tick, but the documentation Here seems to suggest that the physics callbacks run AFTER the tick. The only explanation I can think of is that the following is the actual execution order:

FixedUpdate
Internal Physics
OnTrigger/OnCollision
yield WaitForFixedUpdate()

instead of what is listed in the documentation.

Am I wrong? This is causing some issues with my Eventing system.

Comment
Add comment · Show 2
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 rutter · Nov 19, 2015 at 12:54 AM 1
Share

I don't have a Unity install handy to test this, but if the behavior matches your description then I have to agree that would appear to contradict the docs.

avatar image Owen-Reynolds · Nov 19, 2015 at 04:09 PM 0
Share

I'd toss a 'Time.time' into those Debugs . $$anonymous$$aybe even loop the coroutine 3 or 4 times. $$anonymous$$aybe OnTriggerStay could have an 'if(Trigger)' debug as well.

Trick the system into printing a few frames of the entire execution order for you.

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

when is pysics.raycast used, if it is called in Update() 1 Answer

2D 360 degress platformer example needed 0 Answers

Problem with TriggerEnter/Exit Execution Order 0 Answers

Are rigidbodies only moved in the physics-loop? 1 Answer

Unity Physics Collision Execution Order Error? 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