Example #1
0
 void AssignTargetToAllAgents(Transform target)
 {
     foreach (var agent in agentsToDirect)
     {
         Seek s = agent.GetComponent <Seek>();
         if (s != null)
         {
             s.target = target;
         }
         PathFollowing p = agent.GetComponent <PathFollowing>();
         if (p != null)
         {
             p.target = target;
         }
     }
 }
Example #2
0
 // Assigns target to all agents in 'agentsToDirect'
 void AssignTargetToAllAgents(Transform target)
 {
     // Loop through all agentsToDirect
     foreach (var agent in agentsToDirect)
     {
         Seek s = agent.GetComponent <Seek>();
         if (s != null)
         {
             s.target = target;  // Assign target to seek component on agent
         }
         //Path following
         PathFollowing p = agent.GetComponent <PathFollowing>();
         // Is pathFpllowing attatched to agent?
         if (p != null)
         {
             p.target = target; // Assign target to path following component on agent
         }
     }
 }
 // Assigns target to all agents in 'agentsToDirect'
 void AssignTargetToAllAgents(Transform target)
 {
     foreach (var agent in agentsToDirect)
     {
         Seek          seek          = agent.GetComponent <Seek>();
         PathFollowing pathFollowing = agent.GetComponent <PathFollowing>();
         // If agent has seek attached
         if (seek != null)
         {
             // Set seek target
             seek.target = target;
         }
         // If agent has pathfollowing attached
         if (pathFollowing != null)
         {
             // Set pathfollowing target
             pathFollowing.target = target;
         }
     }
 }
Example #4
0
 // Use this for initialization
 void Start()
 {
     pathFollowing = GetComponent<PathFollowing>();
 }