private void OnTriggerEnter(Collider other) { if (other.gameObject.layer == 21) // 21 = agentlayer { var otherAgent = other.GetComponent <SquadUnit>(); if (otherAgent != null) { if (otherAgent.squadUnitIndex > squadUnitIndex) { Vector3 relativeVector = (transform.position - other.transform.position).normalized; _actions.BreakSpeed(1f); _actions.MoveTowards(transform.position + relativeVector, _complexActions.moveSpeed * 10f); } } } }