Pathing to multiple points

Godot Version

4.7

Question

my code looks like this and im trying to set up a system to have my enemie patrol through 3 diffrent points but whenever i run it they just move to the world origin at 0,0,0

extends CharacterBody3D
@onready var locationmark_1: Node3D = $locationmark1
@onready var locationmark_2: Node3D = $locationmark2
@onready var locationmark_3: Node3D = $locationmark3
@onready var nav_agent = $NavigationAgent3D
var SPEED = 3
func _on_ready():
nav_agent.set_target_position(locationmark_2.global_transform.origin)
func _physics_process(delta: float) → void:
var current_location = global_transform.origin
var nex_location = nav_agent.get_target_position()
var new_velocity = (nex_location - current_location).normalized() * SPEED
velocity = new_velocity
move_and_slide()
func _on_navigation_agent_3d_target_reached() → void:
var node_pool: Array[Node] = [locationmark_1, locationmark_2, locationmark_3]
nav_agent.set_target_position(node_pool.pick_random().global_transform.origin)

Who and when calls _on_ready()?

If you want the function to be called automatically when the node is ready, it must be named _ready()

Thank you so much I wrote that at midnight and now it actully moves to the first spot but once it reaches it it just stops there and doesn’t continue. It seems like it’s not sending the signal for the target area really reached.

Put a print statement into signal handling function to see if it’s getting called.

Yeah it’s just not outputting anything

Is the signal properly connected?

It might not be im out of the house right now but I’ll check that when I get home this evening

I have it set up like this which is as i understand correct

I also tried it with all these signals and none of them outputted anything

func _on_navigation_agent_3d_target_reached() → void:
print(“reached”)
var node_pool: Array[Node] = [locationmark_1, locationmark_2, locationmark_3]
nav_agent.set_target_position(node_pool.pick_random().global_transform.origin)
func _on_navigation_agent_3d_navigation_finished() → void:
print(“reached”)
var node_pool: Array[Node] = [locationmark_1, locationmark_2, locationmark_3]
nav_agent.set_target_position(node_pool.pick_random().global_transform.origin)
pass # Replace with function body.
func _on_navigation_agent_3d_waypoint_reached(details: Dictionary) → void:
print(“reached”)
var node_pool: Array[Node] = [locationmark_1, locationmark_2, locationmark_3]
nav_agent.set_target_position(node_pool.pick_random().global_transform.origin)
func _on_navigation_agent_3d_link_reached(details: Dictionary) → void:
print(“reached”)
var node_pool: Array[Node] = [locationmark_1, locationmark_2, locationmark_3]
nav_agent.set_target_position(node_pool.pick_random().global_transform.origin)

they also all have the same signal setup as the screen shot just with different signals

the scene tree looks like this

nvm changing the signal to finished instead of reached worked and fixed it!