r/Unity3D•
Xerun1

Query about Unity Execution order of same script on multiple game objects

Question

I have a path finding script attached to my enemy units. It finds a position in a grid I’ve defined and then finds the path to that position and then blocks off that position so player and enemy can’t go there and then moves.

The method for pathfinding executes (when a float hits 10f, using Time.Deltatime in update) at the exact same time for 4 gameobjects.

Currently it seems to work fine with each object finding a different optimal position on the grid.

I’m worried eventually the scripts will run exactly at the same time and this will cause problems where either two game objects go to the same location OR when the game suggests the optimal grid position to the pathfinding the grid position is unblocked, but when Pathfinding occurs the position has been blocked by another script.

Do scripts on different gameobjects that execute at the same time actually run individually one at a time or concurrently.

Posted Nov 4, 2022, 1:28 AM UTC · edited

11
Loading comments…