Exemple #1
0
    protected override void OnStopMove()
    {
        pathIterator.MoveNext();
        //print("Next Waypoint: " + pathIterator.Current);

        if (pathIterator.Current == null)
        {
            // finished path once
            switch (mode)
            {
            case NavPath.RepeatMode.Once:
                // done!
                break;

            case NavPath.RepeatMode.Mirror:
                // reverse direction and walk back
                direction = direction == NavPath.FollowDirection.Forward ? NavPath.FollowDirection.Backward : NavPath.FollowDirection.Forward;
                RestartPath();
                MoveAlongPath();
                break;

            case NavPath.RepeatMode.Repeat:
                // start from the beginning
                RestartPath();
                MoveAlongPath();
                break;
            }
        }
    }
Exemple #2
0
    public void SetPath(NavPath path, NavPath.FollowDirection pathDirection = NavPath.FollowDirection.Forward, NavPath.RepeatMode mode = NavPath.RepeatMode.Once)
    {
        Debug.Assert(path != null);

        this.path      = path;
        this.direction = pathDirection;
        this.mode      = mode;

        RestartPath();
    }