(3D) Navigation path becomes triangle and causes stuter

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DanielGameDev_

Godot 3D Pathfinding Bug

Hi there! I hope this is the right place to ask this question.

I’ve been encountering the above issue in regards to pathfinding. It’s infrequent, and I’ve been unable to find any similar post about something like this anywhere.


The following is called in _physics_process:

func autoMovement(delta):

  var current_agent_position: Vector3 = global_position
  var next_path_position: Vector3 = navigation_agent_3d.get_next_path_position()

  var new_velocity: Vector3 = next_path_position - current_agent_position
  new_velocity = new_velocity.normalized()
  new_velocity = new_velocity * 5

  velocity = new_velocity
  move_and_slide()

I’m setting the target position through this function:

func set_movement_target():
   navigation_agent_3d.set_target_position(Vector3(navigationRegion.global_position.x + randf_range(-10, 10), 1.5, navigationRegion.global_position.z + randf_range(-10, 10)))

Which is called on a timer timeout, if the navigation is finished:

func _on_movement_timer_timeout():
	if navigation_agent_3d.is_navigation_finished():
		set_movement_target()

I’d have more of an idea is this was happening consistently, but I can’t seem to identify what woul trigger this behaviour. My assumption is that the issue lies somewhere in the NavAgent Pathfinding settings, or issues with the NavMesh?

Any help would be appreciated - thank you! :smiley:

:bust_in_silhouette: Reply From: smix8

Looks like a navigation mesh issue but could be anything as there is too much random stuff going on in your test scene.

Always test first with a very simple scene, a single agent, without physics and x-other stuff interfering to make sure that your basic navigation setup is working else you will make it hard to identify the source of your bugs.

Are you getting any errors? This triangle path looks like your navigation map had a sync error and was unable to map the navigation mesh polygon edges correctly.