예제 #1
0
    public void SetPath(PathController newController)
    {
        pathController = newController;
        // find all nodes in the path
        var nodeswithPaenrtUnityDum = new List <Transform>(pathController.GetComponentsInChildren <Transform>());

        if (nodeswithPaenrtUnityDum == null)
        {
            Debug.LogError("We got no path nodes, yo.", this);
            this.enabled = false;
        }

        nodeswithPaenrtUnityDum.RemoveAt(0);
        nodes = nodeswithPaenrtUnityDum.ToArray();

        if (nodes == null || nodes.Length == 0)
        {
            Debug.LogError("We got no path nodes, yo.", this);
            this.enabled = false;
        }

        // find the closest node to use as the first node
        currentTargetId = GetClosestPosition(nodes, transform.position);
    }