Will Instantiate in Start()make other objects reach Update()before new object Start()

I am working on some pathfinding code, and to make it easier I created a piece of code the create nodes on the surface of a object the script is attached too.

The problem is that during the first update of the AI the AI creates it’s path so I am wondering of the possible order of events.

Could it be.

WaypointCreater.Start();
Walker.Start();
WaypointCreator.Update()
Instantiate Nodes()
Waker.Update()
Nodes.Start()
???

If this is the case the AI will not be able to track the new nodes added since it’s ran it’s update before Nodes.Start could add them to the static node list.

As I know update is never called before start.

i would agree that first all objects in scene are initialized with awake + start and then the update of all objects start.

if you require the scripts to be executed in a certain order place them in the script execution order. select a script in project view and click script order in the upper right corner of inspector. hope that helps.

It would certainly be easy enough to test. Off the top of my head though I’m pretty sure:

1: Awake happens immediately upon object creation

// class one
void Awake(){
     Instantiate Class Two
     Debug.Log("Class One Awake Finished!");
}

// class two
void Awake(){
     Debug.Log("Class Two Awake Finished!");
}

Would result in:
“Class Two Awake Finished!”
“Class One Awake Finished!”

2: Start happens after the current call stack, but always before the next update

// class one
void Awake(){
     Instantiate Class Two
     Debug.Log("Class One Awake Finished!");
}

void Update(){
     Debug.Log("Class One Updated!");
}

// class two
void Start(){
     Debug.Log("Class Two Awake Finished!");
}

Would result in…
“Class One Awake Finished!”
“Class Two Awake Finished!”
“Class One Updated!”
“Class One Updated!”
“Class One Updated!”
“Class One Updated!”…


Again, that’s just how I remember it working - no promises. I highly suggest making a simple test script and testing it before you build anything large based on that call order.