I am writing an enemy AI that can roam around the map and I am currently running a loop with a random roam distance and then using nav.set_target_location(t_location)
and then running 'nav.is_target_reachable()' to see if it is inside the nav region, however, this approach breaks the updated path signal as it runs the connected function every single time with no way to see if it is the one that will work or not. I'm not sure if there is a way to just check if a position is inside the nav region or if I need to revise how I roam.
Relevant code:
func get_roam_path():
getting_path = true
#print("roam path")
var count = 100
while count > 0:
count -= 1
for direction in directions:
randomize()
directions.shuffle()
var range = randi_range(roam_radius[0], roam_radius[1])
nav_agent.set_target_location(start_pos + direction * range)
#add_path()
if nav_agent.is_target_reachable():
return
print("cant reach")
away_from_start = false