/// <summary> ///Watch the closest protester in the collider zone ///Prevent him from moving beyond your post /// </summary> void Vigil() { float minDist = 100000f; Vector3 dist = Vector3.zero; GetComponent <SteeringController>().orientationBehavior = OrientationBehavior.LookAtTarget; agentComponent.ResetSpeed(); if (agentComponent.collidingAgents.Count != 0 && isBeating == false) { foreach (GameObject c in agentComponent.collidingAgents) { if (c.GetComponent <AgentComponent>().role == (int)RoleName.Protester && c.GetComponent <AgentComponent>().IsFighting() == false) { dist = c.transform.position - transform.position; if (dist.magnitude < minDist) { minDist = dist.magnitude; intruder = c; } } } if (intruder != null && minDist < 4f) { agentComponent.Watch(intruder); if (minDist < 2f) { isBeating = true; intruder.GetComponent <ProtesterBehavior>().GetBeaten(this.gameObject); } else { isBeating = false; } } else { agentComponent.Watch(protestCenter); } } GetComponent <NavMeshAgent>().updateRotation = true; }