protected Vector3 separation() { Vector3 force = Vector3.zero; int neighborCount = 0; for (int i = 0; i < neighbors.Length; i++) { TofuMeleeEnemyAbstract b = neighbors[i]; if (b != this && distance(b.transform.position, this.transform.position) <= SEPARATION_RADIUS) { force.x += b.transform.position.x - this.transform.position.x; force.z += b.transform.position.z - this.transform.position.z; neighborCount++; } } if (neighborCount != 0) { force.x /= neighborCount; force.z /= neighborCount; force *= -1; } force.Normalize(); force *= MAX_SEPARATION; return(force); }
// Start is called before the first frame update void Start() { Tofus = FindObjectOfType <TofuMeleeEnemyAbstract>(); }