4.5 beta 6
I have a problem with Navigation agent 3d, and navigation. For best explanation, look in video>
My nav agent is taking some strange paths, instead of following a direct path to position that they need to go.
4.5 beta 6
I have a problem with Navigation agent 3d, and navigation. For best explanation, look in video>
My nav agent is taking some strange paths, instead of following a direct path to position that they need to go.
I think some code would help.
## MOVEMENT
if moving:
var next_pos = navigation_agent_3d.get_next_path_position()
var move_direction = (next_pos - global_position).normalized()
# Set movement speed based on walk/run
var current_speed = run_speed if is_running else walk_speed
set_move_dir(move_direction * current_speed)
facing_dir = move_direction
## FACING
var fwd = -character_body.global_transform.basis.z
var right = character_body.global_transform.basis.x
var angle_diff = fwd.angle_to(facing_dir)
var turn_dir = 1
if right.dot(facing_dir) > 0:
turn_dir = -1
var turn_amnt = delta * deg_to_rad(turn_speed)
if turn_amnt > angle_diff:
turn_amnt = angle_diff
character_body.global_rotation.y += turn_amnt * turn_dir
Nothing much to see there. Pretty standard.
All the path points in the first vid part are directly in the middle of the navmesh polygon edges so you have path postprocessing edge-centered enabled for whatever reason and need to change it back to corridor-funnel.
In the second part some of the path points make no sense and are likely the result of a too dense navmesh polygon layout. If you have any navmesh polygon merge errors you need to fix them because they are causing it.
So, for anyone looking for an answer:
It turns out that my NavRegion is too big. It is 200x200 m Area.
When I divided Region into smaller chunks, suddenly everything works fine… ![]()
I am glad that you could fixed the issue in some way but need to correct that just changing region size is not a general solution, else people will start downsizing their regions for no reason reading things from the forum (years) later and come to false conclusion.
You would need to go up to really, really high size numbers to encounter float problems on edges where the size is the actual problem and solo problem source. A navmesh size of 200x200m can be considered tiny and can not technically be responsible for any of the problems seen in the video.
If changing the size of the region did anything to help with preventing the path bugs it is most likely that by changing the size to something else it shifted all the geometry rasterization. So having things fixed by changing size was more luck then correlation and might not work at all for other projects that have different geometry. The actual source of the problems where the mentioned polygon edge merge errors caused by cell overlap.
Well, that helped me, every other option didnt, so, logicaly, i thought that was the source of the problem. However thanx for detailed explanation. Hope that this helps someone in future.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.