예제 #1
0
 void OnDeath()
 {
     unitSelection.RemoveTower(this);
     unitSelection.towersDestroyedCount++;
     for (int i = 0; i < numUnitsOnDeath; i++)
     {
         Vector3 randomPos = transform.position + Random.insideUnitSphere * 4f;
         randomPos.y = transform.position.y;
         Vector3 navMeshUnitPosition = randomPos;
         navMeshUnitPosition.y = 0.75f;
         NavMeshAgent   agent    = Instantiate(navMeshUnitPrefab, navMeshUnitPosition, Quaternion.identity).GetComponent <NavMeshAgent>();
         FollowNavAgent follower = Instantiate(unitPrefab, randomPos, Quaternion.identity).GetComponent <FollowNavAgent>();
         follower.agent        = agent;
         follower.raycastPoint = agent.transform.GetChild(0);
     }
 }