Tutorial problem - capsule moves to first waypoint and then stops?

Hi

I have been following the “Get Started With The A* Pathfinding Project” tutorial and or some reason my capsule moves a bit and then stops.

I just did a copy and past of the AstarAI.cs as below and cannot figure out what I did wrong.

The graph seems to be set up correctly as I have dragged a bot into it, set a target and it finds its way there.

Any help much appreciated.

thanks

N

`
using UnityEngine;
using System.Collections;
//Note this line, if it is left out, the script won’t know that the class ‘Path’ exists and it will throw compiler errors
//This line should always be present at the top of scripts which use pathfinding
using Pathfinding;
public class AstarAI : MonoBehaviour {
//The point to move to
public Vector3 targetPosition;

private Seeker seeker;
private CharacterController controller;

//The calculated path
public Path path;

//The AI's speed per second
public float speed = 100;

//The max distance from the AI to a waypoint for it to continue to the next waypoint
public float nextWaypointDistance = 3;

//The waypoint we are currently moving towards
private int currentWaypoint = 0;

public void Start () {
    seeker = GetComponent<Seeker>();
    controller = GetComponent<CharacterController>();
    
    //Start a new path to the targetPosition, return the result to the OnPathComplete function
    seeker.StartPath (transform.position,targetPosition, OnPathComplete);
}

public void OnPathComplete (Path p) {
    Debug.Log ("Yey, we got a path back. Did it have an error? "+p.error);
    if (!p.error) {
        path = p;
        //Reset the waypoint counter
        currentWaypoint = 0;
    }
}

public void OnDisable () {
	seeker.pathCallback -= OnPathComplete;
} 

public void FixedUpdate () {
    if (path == null) {
        //We have no path to move after yet
		Debug.Log ("no path");
        return;
    }
    
    if (currentWaypoint >= path.vectorPath.Length) {
        Debug.Log ("End Of Path Reached");
        return;
    }
    
    //Direction to the next waypoint
    Vector3 dir = (path.vectorPath[currentWaypoint]-transform.position).normalized;
    dir *= speed * Time.fixedDeltaTime;
    controller.SimpleMove (dir);
	Debug.Log ("moving amount = " +dir);
    
    //Check if we are close enough to the next waypoint
    //If we are, proceed to follow the next waypoint
    if (Vector3.Distance (transform.position,path.vectorPath[currentWaypoint]) < nextWaypointDistance) {
        currentWaypoint++;
		Debug.Log ("currentWaypoint = "+currentWaypoint);
        return;
    }
}

}`

I cannot see anything wrong with that script. It should find the path to the target and move there. Setting the nextWaypointDistance to a too low value?. Are you wondering about why it does not continue to follow the target after it has reached the initial target? For that you need to call StartPath repeatedly, for example using a coroutine to call it every second or so.

I have the same problem, in my case the seeker gets halfway through the path and I get the “End of Path Reached” state.

Increasing nextWaypointDistance has no effect. Reducing it to 1, gets him to navigate it a bit better, but he still stops short of the destination.

Actually this appears to be a problem with the Tutorial script AstarAI.cs … I’ve switched to AIPath.cs as someone suggested in an earlier post and that seems to be working.

Although now I have an issue with the seeker not being able to follow a path to the opposite side of a wall (and the path appears to be starting at negative 0.5 in Y… something to figure out for myself I guess.

Deleting and making a new graph fixed my , probably got messed up with me turning all the options inside out.