1
0
Fork 0

Merge pull request #77110 from smix8/fix_agent_avoidance_pos_4.0

[4.0] Fix agent avoidance position not updated when entering SceneTree
This commit is contained in:
Rémi Verschelde 2023-06-22 21:00:50 +02:00 committed by GitHub
commit 5fdd5fa19d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 0 deletions

View File

@ -151,6 +151,10 @@ void NavigationAgent2D::_notification(int p_what) {
set_agent_parent(get_parent());
set_physics_process_internal(true);
if (agent_parent && avoidance_enabled) {
NavigationServer2D::get_singleton()->agent_set_position(agent, agent_parent->get_global_position());
}
#ifdef DEBUG_ENABLED
if (NavigationServer2D::get_singleton()->get_debug_enabled()) {
debug_path_dirty = true;

View File

@ -63,6 +63,9 @@ void NavigationObstacle2D::_notification(int p_what) {
case NOTIFICATION_POST_ENTER_TREE: {
set_agent_parent(get_parent());
set_physics_process_internal(true);
if (parent_node2d && parent_node2d->is_inside_tree()) {
NavigationServer2D::get_singleton()->agent_set_position(agent, parent_node2d->get_global_position());
}
} break;
case NOTIFICATION_EXIT_TREE: {

View File

@ -154,6 +154,10 @@ void NavigationAgent3D::_notification(int p_what) {
set_agent_parent(get_parent());
set_physics_process_internal(true);
if (agent_parent && avoidance_enabled) {
NavigationServer3D::get_singleton()->agent_set_position(agent, agent_parent->get_global_position());
}
#ifdef DEBUG_ENABLED
if (NavigationServer3D::get_singleton()->get_debug_enabled()) {
debug_path_dirty = true;

View File

@ -62,6 +62,9 @@ void NavigationObstacle3D::_notification(int p_what) {
case NOTIFICATION_POST_ENTER_TREE: {
set_agent_parent(get_parent());
set_physics_process_internal(true);
if (parent_node3d && parent_node3d->is_inside_tree()) {
NavigationServer3D::get_singleton()->agent_set_position(agent, parent_node3d->get_global_position());
}
} break;
case NOTIFICATION_EXIT_TREE: {