Need help with Navmesh (again)

I’m trying to make a 3d pacman game, and I’ve set up the ghost’s navmesh. It patrols between the waypoints (the blue diamonds). Now, I made it so that the ghosts shoots a raycast and when that raycast hits pacman (the player), the destination is then set to pacman. This works… kinda.


As you can see, the ghosts are sort of following the player? but keeping at a certain distance.

I don’t know how to fix this. I want the ghosts to go right up to pacman so that they hit him.

void Update()
    // If chasing, check for Pac-Man and navigate accordingly
    if (CanSeePacman()) {
        Debug.Log("Chasing Pacman");
        agent.isStopped = false;
    } else {
        // If not chasing, patrol between waypoints

Here’s my script. It’s relatively simple? I actually have a function called ChasePacman(). It replaces the agent.setdestination(pacman.position). The problem is, the ghosts immediately stop moving when I cross the raycast. They won’t continue moving after that.

Here’s the function:

void ChasePacman ()
    isChasing = true;
    agent.destination = pacman.position;
    Debug.Log("Setting destination to Pacman");

The original script didn’t include a return, and when I tried adding it, still same results.

The ghost also stops chasing the player the second the player steps out of view of the raycast, but I think I can fix this by locking the rotation of the ghost to face pacman the second he hits the raycast. Although that would be weird for the maze, causing the ghosts to clip through the walls.

Any workarounds for this?