void Awake() { // Initialize components and visual effects hidden InitializeSelectionHighlight(); InitializeMiniMapIcon(); InitializeParticleEffects(); HealthBar = GetComponentInChildren <HealthBarManager>(); maxHealth = Health; UnitID = UnitTracker.GetNewUnitID(); // Minimum degree angle required to skip the unit rotation, above will require rotate toward destination PermissiveDestinationAngleDelta = 1; // If the unit is already in the scene when launching the game, setting the destination to the current // position of the GameObject here has the same result as setting it at the variable declaration above. // But, if a new unit instance is requested while the game is running, the reference of the unit to be // instanciated will immediately exist while the actual instance will only be generated on the next frame. // Therefore, 'MoveToDestination' could be called to set the desired destination, but it would immediately // be overriden by the first 'Start' call when it is instanciated on the next frame. // Setting the variable in the 'Start' call resolves the problem no matter when the unit is instanciated. if (destinationRequest.Equals(Vector3.zero)) { destinationRequest = transform.position; } }