order of scripts
For some collision calculations i created a child of "Player" which have a Collider2D My idea was to while dashing the player would calculate if he could move further or not by first moving his child by the dashing speed. If the child didnt collide with anything the player would move to the child position otherwise the dash would stop and the collider would return to the player position. But how do i garantee the child script will always be after the player script
Answer by JVene · Dec 21, 2018 at 12:47 AM
Examine the documentation on Execution Order, specifically the cycle of the physics engine cycle with both FixedUpdate and the collision triggers.
The physics engine is not going to give you much control over the order in which scripted objects will receive notifications.
You may do better by issuing ray casts to implement what you intend, or something related like a sphere cast.
If for some reason you can't use sphere casts, you will need to consider your timing requirement given the cycle of events you see in the documentation. FixedUpdate is called before you receive collision messages, but notice that the cycle then returns to the FixedUpdate at the next cycle of the physics engine (as, too, the Update function will follow, but at the rate of the frame rate, not the physics rate).
You may be able to re-envision your existing plan by responding to collected information from the collision response in the next FixedUpdate (feeding the collision test information into the next FixedUpdate).