summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorsmix8 <52464204+smix8@users.noreply.github.com>2021-04-16 22:04:02 +0200
committersmix8 <52464204+smix8@users.noreply.github.com>2021-04-16 22:04:02 +0200
commitcd24a63da2efd8f5b6bdc0072e81c35e2d1986fe (patch)
tree5205eb5d715274d54cb75079ca7c6082d3b0e660 /scene/2d
parentb8bd648ad9b530e4e29424efe3a9d0b19387d998 (diff)
Fix NavigationAgent2D not emitting "target_reached" Signal reliably
Fix NavigationAgent2D not emitting "target_reached" Signal reliably
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/navigation_agent_2d.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp
index a18687afed..0d23afe77f 100644
--- a/scene/2d/navigation_agent_2d.cpp
+++ b/scene/2d/navigation_agent_2d.cpp
@@ -301,6 +301,12 @@ void NavigationAgent2D::update_navigation() {
while (o.distance_to(navigation_path[nav_path_index]) < target_desired_distance) {
nav_path_index += 1;
if (nav_path_index == navigation_path.size()) {
+ if (!target_reached) {
+ if (distance_to_target() < target_desired_distance) {
+ emit_signal("target_reached");
+ target_reached = true;
+ }
+ }
nav_path_index -= 1;
navigation_finished = true;
emit_signal("navigation_finished");