Exemple #1
0
    public void FollowPath()
    {
        if (!onRoute)
        {
            return;
        }

        float distReq     = (nextNode - prevNode).sqrMagnitude;
        float disTraveled = (myTransform.position - prevNode).sqrMagnitude;

        if (disTraveled >= distReq)
        {
            if (currentPath.Count == goalIndex + 1)
            {
                onRoute = false;
                inputs.forwardBackwardInput = 0;
                inputs.leftRightInput       = 0;
            }
            else
            {
                prevNode = nextNode;
                nextNode = currentPath[++goalIndex];
                moveToNextNode();
            }
        }

        onRoute = NavMesh.CheckReachable(prevNode, nextNode);
    }