private void CheckPursueAndSave() { if (team == null) { return; } if (state == State.PURSUE && Vector3.Distance(transform.position, chasing.transform.position) < 0.1f) //if it is pursuing and hits the target { state = State.WANDER; //puts its own state back to wandering (the aiTeam script will assign it something else if needed) chasing.state = State.FROZEN; //puts the enemy state to frozen Transform flag; if ((flag = GetFlag(chasing.transform)) != null) //if the enemy had a flag it will return it to its base { flag.transform.parent = GameObject.Find(flag.tag + "FlagBase").transform; flag.localPosition = Vector3.zero; } team.StopChaseHim(chasing.transform); } else if (state == State.SAVING && Vector3.Distance(transform.position, target) < 0.1f) //if it hits a frozen ally gets them both back to wandering { state = State.WANDER; chasing.state = State.WANDER; } }
private void OnCollisionExit(Collision collision) //if a player leaves the plane on a board extremity, teleport it to the other end { if (collision.transform.position.x > maxX) { collision.transform.position -= maxXVec; } if (collision.transform.position.x < -maxX) { collision.transform.position += maxXVec; } if (collision.transform.position.z > maxZ) { collision.transform.position -= maxZVec; } if (collision.transform.position.z < -maxZ) { collision.transform.position += maxZVec; } if (collision.transform.CompareTag(tag) && !TestScene) { aiTeam.StopChaseHim(collision.transform); } }