I want to inform other near by agents to the playerPos
but when i call followPlayer() in the Update i get 1-2 fps
I need help there must be other way to do it right ?
List NearBy() {
foreach (GameObject zombie in zombies)
{
float distance= Vector3.Distance(transform.position, zombie.transform.position);
if (distance<=radius)
{
nearByZombie.Add(zombie);
}
}
return (nearByZombie);
}
public void followPlayer()
{
foreach (GameObject zombie in NearBy())
{
if (DistanceBetweenPlayerAndZombie())
{
Movement agentMovement = zombie.transform.GetComponent<Movement>();
agentMovement.agent.SetDestination(player.position);
}
}
},I'm want to inform other near by agent to the playerPos
when i run SwampAi i get 2 fps is there is a better way of doing this ?
List NearBy() {
foreach (GameObject zombie in zombies)
{
float distance= Vector3.Distance(transform.position, zombie.transform.position);
if (distance<=radius)
{
nearByZombie.Add(zombie);
}
}
return (nearByZombie);
}
public void SwampAi()
{
foreach (GameObject zombie in NearBy())
{
if (DistanceBetweenPlayerAndZombie())
{
Movement agentMovement = zombie.transform.GetComponent<Movement>();
agentMovement.agent.SetDestination(player.position);
}
}
}