Add NavigationAgent desired path distance
Add NavigationAgent desired path distance
This commit is contained in:
@@ -40,6 +40,9 @@ void NavigationAgent2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_avoidance_enabled", "enabled"), &NavigationAgent2D::set_avoidance_enabled);
|
||||
ClassDB::bind_method(D_METHOD("get_avoidance_enabled"), &NavigationAgent2D::get_avoidance_enabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_desired_distance", "desired_distance"), &NavigationAgent2D::set_path_desired_distance);
|
||||
ClassDB::bind_method(D_METHOD("get_path_desired_distance"), &NavigationAgent2D::get_path_desired_distance);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_target_desired_distance", "desired_distance"), &NavigationAgent2D::set_target_desired_distance);
|
||||
ClassDB::bind_method(D_METHOD("get_target_desired_distance"), &NavigationAgent2D::get_target_desired_distance);
|
||||
|
||||
@@ -81,6 +84,7 @@ void NavigationAgent2D::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_avoidance_done", "new_velocity"), &NavigationAgent2D::_avoidance_done);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01,suffix:px"), "set_path_desired_distance", "get_path_desired_distance");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01,suffix:px"), "set_target_desired_distance", "get_target_desired_distance");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.1,500,0.01,suffix:px"), "set_radius", "get_radius");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "neighbor_dist", PROPERTY_HINT_RANGE, "0.1,100000,0.01,suffix:px"), "set_neighbor_dist", "get_neighbor_dist");
|
||||
@@ -234,6 +238,10 @@ RID NavigationAgent2D::get_navigation_map() const {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void NavigationAgent2D::set_path_desired_distance(real_t p_dd) {
|
||||
path_desired_distance = p_dd;
|
||||
}
|
||||
|
||||
void NavigationAgent2D::set_target_desired_distance(real_t p_dd) {
|
||||
target_desired_distance = p_dd;
|
||||
}
|
||||
@@ -399,7 +407,7 @@ void NavigationAgent2D::update_navigation() {
|
||||
// Check if we can advance the navigation path
|
||||
if (navigation_finished == false) {
|
||||
// Advances to the next far away location.
|
||||
while (o.distance_to(navigation_path[nav_path_index]) < target_desired_distance) {
|
||||
while (o.distance_to(navigation_path[nav_path_index]) < path_desired_distance) {
|
||||
nav_path_index += 1;
|
||||
if (nav_path_index == navigation_path.size()) {
|
||||
_check_distance_to_target();
|
||||
|
||||
@@ -47,6 +47,7 @@ class NavigationAgent2D : public Node {
|
||||
bool avoidance_enabled = false;
|
||||
uint32_t navigation_layers = 1;
|
||||
|
||||
real_t path_desired_distance = 1.0;
|
||||
real_t target_desired_distance = 1.0;
|
||||
real_t radius = 0.0;
|
||||
real_t neighbor_dist = 0.0;
|
||||
@@ -91,6 +92,11 @@ public:
|
||||
void set_navigation_map(RID p_navigation_map);
|
||||
RID get_navigation_map() const;
|
||||
|
||||
void set_path_desired_distance(real_t p_dd);
|
||||
real_t get_path_desired_distance() const {
|
||||
return path_desired_distance;
|
||||
}
|
||||
|
||||
void set_target_desired_distance(real_t p_dd);
|
||||
real_t get_target_desired_distance() const {
|
||||
return target_desired_distance;
|
||||
|
||||
@@ -38,6 +38,9 @@ void NavigationAgent3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_avoidance_enabled", "enabled"), &NavigationAgent3D::set_avoidance_enabled);
|
||||
ClassDB::bind_method(D_METHOD("get_avoidance_enabled"), &NavigationAgent3D::get_avoidance_enabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_desired_distance", "desired_distance"), &NavigationAgent3D::set_path_desired_distance);
|
||||
ClassDB::bind_method(D_METHOD("get_path_desired_distance"), &NavigationAgent3D::get_path_desired_distance);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_target_desired_distance", "desired_distance"), &NavigationAgent3D::set_target_desired_distance);
|
||||
ClassDB::bind_method(D_METHOD("get_target_desired_distance"), &NavigationAgent3D::get_target_desired_distance);
|
||||
|
||||
@@ -85,6 +88,7 @@ void NavigationAgent3D::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_avoidance_done", "new_velocity"), &NavigationAgent3D::_avoidance_done);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01,suffix:m"), "set_path_desired_distance", "get_path_desired_distance");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01,suffix:m"), "set_target_desired_distance", "get_target_desired_distance");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.1,100,0.01,suffix:m"), "set_radius", "get_radius");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "agent_height_offset", PROPERTY_HINT_RANGE, "-100.0,100,0.01,suffix:m"), "set_agent_height_offset", "get_agent_height_offset");
|
||||
@@ -241,6 +245,10 @@ RID NavigationAgent3D::get_navigation_map() const {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void NavigationAgent3D::set_path_desired_distance(real_t p_dd) {
|
||||
path_desired_distance = p_dd;
|
||||
}
|
||||
|
||||
void NavigationAgent3D::set_target_desired_distance(real_t p_dd) {
|
||||
target_desired_distance = p_dd;
|
||||
}
|
||||
@@ -416,7 +424,7 @@ void NavigationAgent3D::update_navigation() {
|
||||
// Check if we can advance the navigation path
|
||||
if (navigation_finished == false) {
|
||||
// Advances to the next far away location.
|
||||
while (o.distance_to(navigation_path[nav_path_index] - Vector3(0, navigation_height_offset, 0)) < target_desired_distance) {
|
||||
while (o.distance_to(navigation_path[nav_path_index] - Vector3(0, navigation_height_offset, 0)) < path_desired_distance) {
|
||||
nav_path_index += 1;
|
||||
if (nav_path_index == navigation_path.size()) {
|
||||
_check_distance_to_target();
|
||||
|
||||
@@ -47,6 +47,7 @@ class NavigationAgent3D : public Node {
|
||||
bool avoidance_enabled = false;
|
||||
uint32_t navigation_layers = 1;
|
||||
|
||||
real_t path_desired_distance = 1.0;
|
||||
real_t target_desired_distance = 1.0;
|
||||
real_t radius = 0.0;
|
||||
real_t navigation_height_offset = 0.0;
|
||||
@@ -93,6 +94,11 @@ public:
|
||||
void set_navigation_map(RID p_navigation_map);
|
||||
RID get_navigation_map() const;
|
||||
|
||||
void set_path_desired_distance(real_t p_dd);
|
||||
real_t get_path_desired_distance() const {
|
||||
return path_desired_distance;
|
||||
}
|
||||
|
||||
void set_target_desired_distance(real_t p_dd);
|
||||
real_t get_target_desired_distance() const {
|
||||
return target_desired_distance;
|
||||
|
||||
Reference in New Issue
Block a user