- Home /
Why does my navmesh pathfinding get screwed up after i hit a wall?
i have a creature with a navmesh agent, a rigidbody, and a collider. Here are the parameters on all three
Here's the area i'm working with, it's a simple square playpen, with the sides nd floor set to navmesh static. Note the navmesh in the middle. I do not know why this isn't sitting perfectly in there, but it isn't. the navmesh seems to slope upwards towards the lowerleft corner, despite the floor being utterly flat.
The puppy can path around this area just fine. i've got it set to run to the spot where ik click, this has no adverse effects. It stops pretty close to the target point:
However i have a problem. If i click on the walls of the pen (which are not pathable, as seen in the navmesh picture) then things start to get screwed up. The puppy bounces off them, and then becomes unable to properly navigate to anything until i exit and restart play mode
Here's an example of the puppy bouncing off then getting screwed up:
And then after that, until i restart play mode, he becomes unable to come to a rest on a target spot, instead fidgeting around it endlessly, like this:
So yea, what gieves? If the nav mesh agent is given a target it can't path to, shouldn't it either get as close as it can and then stop, or just refuse to move at all? How is the puppy pathing to these areas, and why is it subsequently getting messed up
Is there any information i could provide that would assist in debugging this? I'm quite new to pathfinding and navmeshes.
As a general rule, you don't use physics when you're moving with a navmesh agent. Either remove the rigidbody, or if you need it, turn it static.
Debug the current path with NavmeshAgent.pathStatus, that'll give you "complete", which means that the path exists, "partial", which means that the agent can get some of the way, or "invalid", which means that the agent cannot move.
You can also look into the path (agent.path), which contains an array of corners, which are the points at which the agent will move through.
Finally, make sure that you're reading your console messages. The error you're getting is probably accompanied by something along the lines of "the agent has to be placed on a navmesh!"
I am using physics, 100% certain. if that interferes with navmesh agents then i won't use navmesh agents. Is it possible to get the list of path coordinates and handle moving to them myself?
For that matter, has anyone written a physical navmeshagent class ?
i'll look into that
In our game, I'm moving manually based on the navmesh. You do that by ditching the navmesh agent, and using the static method Nav$$anonymous$$esh.CalculatePath to get a path that you can follow.
thank you baste. But this sort of manual pathing seems to open a can of worms. ie, there's lots of problems like the overshooting thing, and the autobraking near the target point. parts of the navmehagent i'd really like to have in physical movement.
Certainly i can replicate it all, but hasn';t anyone already done that? i'd rather use a pre-written library.
Your answer
Follow this Question
Related Questions
Navmesh Path is shown even between disconnected regions.? 0 Answers
Lack of Bi-Direction OffMeshLinks for Jumping Up? 0 Answers
Instantiated objects at beginning of runtime are messing with the pathing for my NavMesh. 0 Answers
Find the nearest location and move to a target outside Navigation Mesh? 1 Answer
NavMesh Agent glitches on navmesh edges 2 Answers