mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 11:56:49 +01:00
Backported from godot4: Stops NavigationAgents moving to the world origin without anyone telling them to do so.
-smix8
860379fc16
This commit is contained in:
parent
61bf4df2f4
commit
2dc300a0fc
@ -248,7 +248,7 @@ void NavigationAgent2D::_notification(int p_what) {
|
||||
#endif // DEBUG_ENABLED
|
||||
} break;
|
||||
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
|
||||
if (agent_parent) {
|
||||
if (agent_parent && target_position_submitted) {
|
||||
if (velocity_submitted) {
|
||||
velocity_submitted = false;
|
||||
if (avoidance_enabled) {
|
||||
@ -573,6 +573,7 @@ real_t NavigationAgent2D::get_path_max_distance() {
|
||||
|
||||
void NavigationAgent2D::set_target_position(Vector2 p_position) {
|
||||
target_position = p_position;
|
||||
target_position_submitted = true;
|
||||
_request_repath();
|
||||
}
|
||||
|
||||
@ -663,6 +664,10 @@ void NavigationAgent2D::update_navigation() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target_position_submitted) {
|
||||
return;
|
||||
}
|
||||
|
||||
update_frame_id = Engine::get_singleton()->get_physics_frames();
|
||||
|
||||
Vector2 origin = agent_parent->get_global_transform().get_origin();
|
||||
@ -788,6 +793,7 @@ void NavigationAgent2D::update_navigation() {
|
||||
_check_distance_to_target();
|
||||
nav_path_index -= 1;
|
||||
navigation_finished = true;
|
||||
target_position_submitted = false;
|
||||
emit_signal("navigation_finished");
|
||||
break;
|
||||
}
|
||||
|
@ -66,6 +66,8 @@ class NavigationAgent2D : public Node {
|
||||
real_t path_max_distance;
|
||||
|
||||
Vector2 target_position;
|
||||
bool target_position_submitted;
|
||||
|
||||
Ref<NavigationPathQueryParameters2D> navigation_query;
|
||||
Ref<NavigationPathQueryResult2D> navigation_result;
|
||||
int nav_path_index;
|
||||
@ -84,8 +86,6 @@ class NavigationAgent2D : public Node {
|
||||
Vector2 velocity_forced;
|
||||
bool velocity_forced_submitted;
|
||||
|
||||
bool target_position_submitted;
|
||||
|
||||
bool target_reached;
|
||||
bool navigation_finished;
|
||||
// No initialized on purpose
|
||||
|
@ -550,6 +550,7 @@ real_t NavigationAgent::get_path_max_distance() {
|
||||
|
||||
void NavigationAgent::set_target_position(Vector3 p_position) {
|
||||
target_position = p_position;
|
||||
target_position_submitted = true;
|
||||
_request_repath();
|
||||
}
|
||||
|
||||
@ -648,6 +649,10 @@ void NavigationAgent::update_navigation() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target_position_submitted) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (update_frame_id == Engine::get_singleton()->get_physics_frames()) {
|
||||
return;
|
||||
}
|
||||
@ -773,6 +778,7 @@ void NavigationAgent::update_navigation() {
|
||||
_check_distance_to_target();
|
||||
nav_path_index -= 1;
|
||||
navigation_finished = true;
|
||||
target_position_submitted = false;
|
||||
emit_signal("navigation_finished");
|
||||
break;
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ class NavigationAgent : public Node {
|
||||
real_t path_max_distance;
|
||||
|
||||
Vector3 target_position;
|
||||
bool target_position_submitted;
|
||||
|
||||
Ref<NavigationPathQueryParameters3D> navigation_query;
|
||||
Ref<NavigationPathQueryResult3D> navigation_result;
|
||||
@ -96,8 +97,6 @@ class NavigationAgent : public Node {
|
||||
// While not perfect it at least looks way better than agent's that clip through everything that is not a flat surface
|
||||
float stored_y_velocity;
|
||||
|
||||
bool target_position_submitted;
|
||||
|
||||
bool target_reached;
|
||||
bool navigation_finished;
|
||||
// No initialized on purpose
|
||||
|
Loading…
Reference in New Issue
Block a user