void Objective()
    {
        switchedStates = false;
        //Check if there is combat.
        if (Self.visibleEnemyLocations.Count != 0 || Self.attackedFromLocations.Count != 0)
        {
            CombatTime = .5f;
            state      = 1;
        }


        //Check if target objective has been taken
        if (ActiveObjective.getControllingTeam() == KEYBOARD_WARRIORS.ourTeamColor)
        {
            ActiveObjective = ChooseNewObjective();
        }

        //Spin
        Self.rotateAngle(150);

        //If low hp then get items
        foreach (var item in Self.getItemList())
        {
            if (Self.getHP() < 50 && Self.getItemList().Count > 0 && Mathf.Abs((item.transform.position - Self.transform.position).magnitude) < 40)
            {
                itemTime       = 5;
                switchedStates = true;
                state          = 2;
            }
        }
        //If an item is near and not an objective get item
        foreach (var item in Self.getItemList())
        {
            if (Mathf.Abs((item.transform.position - Self.transform.position).magnitude) < 10)
            {
                switchedStates = true;
                itemTime       = 2;
                state          = 2;
            }
        }

        //Move to objective.
        Self.MoveChar(ActiveObjective.getObjectiveLocation());
    }
 float DistanceToObjective(ObjectiveScript s, CharacterScript c)
 {
     return(Mathf.Abs((s.getObjectiveLocation() - c.transform.position).magnitude));
 }