Exemple #1
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);
        }
    }
Exemple #2
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);
    }