예제 #1
0
    void UpdateUnitTargets()
    {
        GameObject empty = new GameObject();

        if (markers != null)
        {
            for (int i = 0; i < markers.Length; i++)
            {
                Destroy(markers[i]);
            }
        }
        markers = new GameObject[current_formation.offset_from_lead.Length];
        if (leader == null)
        {
            return;
        }
        for (int i = 0; i < markers.Length; i++)
        {
            markers[i] = current_formation.GenerateMarker(empty, (leader.transform.rotation * current_formation.offset_from_lead[i]) + leader.transform.position, Quaternion.identity, leader.transform);

            if (i < units.Count)
            {
                units[i].target = markers[i].transform;
            }
        }
        if (leader != null)
        {
            leader.target = squad_target;
        }

        Destroy(empty);
    }