Godot Version
v4.3.stable.steam
Question
To be shorter, I have NPC chatacter which:
- Explores the place
- Chases a player if finds him
- Continues to explore if lost or catched up the player
There will be more than one player, so the NPC will have to choose one of them, first I would like to do the simplest logic - to catch the one who is closer to him.
It means I need to get each path length to the players. Is there a way to get length to each target without changing NavigationAgent’s target? Because NPC is moving each frame by this path - and if I change it each time just to check - NPC will change his path for a second and it will look weird
Now I decided to create second NavigationAgent just for finding the shortest path (In screenshot “DestinationAgent3D” node). Maybe there’re better solutins?
Something like - distance_to_target(target: Vector3) -> float