On race conditions: Awake comes before Start comes before Update

At 4:20-4:50 Ben notes a race condition where the path finder might be called after the enemy looks for a path. You could fix this by having all the PathFinder intialisation stuff in a Awake() and the enemy initialisation stuff in a Start(). Eg the PathFinder will build a massive dictionary of shortest paths between any two points in its Awake(), and then enemies in call their Start() functions to find their best route. This fixes the race because Awake ALWAYS precedes Start. Also it means the game scene/level can take a few seconds to load (ie run it’s Awake() functions) without ruining the frame-rate of the main game play.

1 Like

Privacy & Terms