mirror of
https://github.com/godotengine/godot
synced 2024-11-02 14:43:31 +00:00
Merge pull request #48229 from smix8/issue_47334_navagent3d_target_reached
Fix NavigationAgent3D not emitting "target_reached" Signal
This commit is contained in:
commit
3dfb740a20
2 changed files with 12 additions and 6 deletions
|
@ -111,12 +111,7 @@ void NavigationAgent3D::_notification(int p_what) {
|
|||
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
|
||||
if (agent_parent) {
|
||||
NavigationServer3D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin);
|
||||
if (!target_reached) {
|
||||
if (distance_to_target() < target_desired_distance) {
|
||||
emit_signal("target_reached");
|
||||
target_reached = true;
|
||||
}
|
||||
}
|
||||
_check_distance_to_target();
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
@ -314,6 +309,7 @@ void NavigationAgent3D::update_navigation() {
|
|||
while (o.distance_to(navigation_path[nav_path_index] - Vector3(0, navigation_height_offset, 0)) < target_desired_distance) {
|
||||
nav_path_index += 1;
|
||||
if (nav_path_index == navigation_path.size()) {
|
||||
_check_distance_to_target();
|
||||
nav_path_index -= 1;
|
||||
navigation_finished = true;
|
||||
emit_signal("navigation_finished");
|
||||
|
@ -322,3 +318,12 @@ void NavigationAgent3D::update_navigation() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NavigationAgent3D::_check_distance_to_target() {
|
||||
if (!target_reached) {
|
||||
if (distance_to_target() < target_desired_distance) {
|
||||
emit_signal("target_reached");
|
||||
target_reached = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,6 +147,7 @@ public:
|
|||
|
||||
private:
|
||||
void update_navigation();
|
||||
void _check_distance_to_target();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue