Beispiel #1
0
    /// <summary>
    /// Initializes the Waypoint stuff, to include setting the initialze direction.
    /// </summary>
    private void InitializeWaypointDestination()
    {
        Assert.IsNotNull(this.network, "NavAgentExample: 'Way Point Network' is missing; did you forget to set it in inspector!");

        engine = new WaypointEngine(this.network);

        if (this.currentWaypoint == null)
        {
            this.currentWaypoint = engine.GetWaypoint(network.PathStartIndex);
        }

        SetWaypointDestination(false);
    }
Beispiel #2
0
    /// <summary>
    /// Displays nav mesh paths in the scene.
    /// </summary>
    private void DisplayPaths()
    {
        AiWaypointNetwork network      = (AiWaypointNetwork)target;
        WaypointEngine    engine       = new WaypointEngine(network);
        Waypoint          fromWaypoint = engine.GetWaypoint(network.PathStartIndex);
        Waypoint          toWaypoint   = engine.GetWaypoint(network.PathEndIndex);

        if (fromWaypoint != null && fromWaypoint.Transform != null && toWaypoint != null && toWaypoint.Transform != null)
        {
            NavMeshPath path = new NavMeshPath();
            NavMesh.CalculatePath(fromWaypoint.Transform.position, toWaypoint.Transform.position, NavMesh.AllAreas, path);
            Handles.color = Color.yellow;
            Handles.DrawPolyLine(path.corners);
        }
    }
Beispiel #3
0
 /// <summary>
 /// Initialize the waypoint network, to include creating an error if it does not exist.  Also
 /// sets the current waypoint to the next waypoint, taking into account shouldPatrolRandomly.
 /// </summary>
 private void InitializeWaypointNetwork()
 {
     this.waypointEngine = new WaypointEngine(this.waypointNetwork);
     SetNextWayPoint();
 }