|
@@ -62,6 +62,9 @@ void NavigationAgent3D::_bind_methods() {
|
|
ClassDB::bind_method(D_METHOD("set_path_max_distance", "max_speed"), &NavigationAgent3D::set_path_max_distance);
|
|
ClassDB::bind_method(D_METHOD("set_path_max_distance", "max_speed"), &NavigationAgent3D::set_path_max_distance);
|
|
ClassDB::bind_method(D_METHOD("get_path_max_distance"), &NavigationAgent3D::get_path_max_distance);
|
|
ClassDB::bind_method(D_METHOD("get_path_max_distance"), &NavigationAgent3D::get_path_max_distance);
|
|
|
|
|
|
|
|
+ ClassDB::bind_method(D_METHOD("set_navigable_layers", "navigable_layers"), &NavigationAgent3D::set_navigable_layers);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("get_navigable_layers"), &NavigationAgent3D::get_navigable_layers);
|
|
|
|
+
|
|
ClassDB::bind_method(D_METHOD("set_target_location", "location"), &NavigationAgent3D::set_target_location);
|
|
ClassDB::bind_method(D_METHOD("set_target_location", "location"), &NavigationAgent3D::set_target_location);
|
|
ClassDB::bind_method(D_METHOD("get_target_location"), &NavigationAgent3D::get_target_location);
|
|
ClassDB::bind_method(D_METHOD("get_target_location"), &NavigationAgent3D::get_target_location);
|
|
ClassDB::bind_method(D_METHOD("get_next_location"), &NavigationAgent3D::get_next_location);
|
|
ClassDB::bind_method(D_METHOD("get_next_location"), &NavigationAgent3D::get_next_location);
|
|
@@ -85,6 +88,7 @@ void NavigationAgent3D::_bind_methods() {
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "max_speed", PROPERTY_HINT_RANGE, "0.1,10000,0.01"), "set_max_speed", "get_max_speed");
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "max_speed", PROPERTY_HINT_RANGE, "0.1,10000,0.01"), "set_max_speed", "get_max_speed");
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_max_distance", PROPERTY_HINT_RANGE, "0.01,100,0.1"), "set_path_max_distance", "get_path_max_distance");
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_max_distance", PROPERTY_HINT_RANGE, "0.01,100,0.1"), "set_path_max_distance", "get_path_max_distance");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ignore_y"), "set_ignore_y", "get_ignore_y");
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ignore_y"), "set_ignore_y", "get_ignore_y");
|
|
|
|
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "navigable_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigable_layers", "get_navigable_layers");
|
|
|
|
|
|
ADD_SIGNAL(MethodInfo("path_changed"));
|
|
ADD_SIGNAL(MethodInfo("path_changed"));
|
|
ADD_SIGNAL(MethodInfo("target_reached"));
|
|
ADD_SIGNAL(MethodInfo("target_reached"));
|
|
@@ -133,6 +137,18 @@ NavigationAgent3D::~NavigationAgent3D() {
|
|
agent = RID(); // Pointless
|
|
agent = RID(); // Pointless
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void NavigationAgent3D::set_navigable_layers(uint32_t p_layers) {
|
|
|
|
+ bool layers_changed = navigable_layers != p_layers;
|
|
|
|
+ navigable_layers = p_layers;
|
|
|
|
+ if (layers_changed) {
|
|
|
|
+ _request_repath();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+uint32_t NavigationAgent3D::get_navigable_layers() const {
|
|
|
|
+ return navigable_layers;
|
|
|
|
+}
|
|
|
|
+
|
|
void NavigationAgent3D::set_target_desired_distance(real_t p_dd) {
|
|
void NavigationAgent3D::set_target_desired_distance(real_t p_dd) {
|
|
target_desired_distance = p_dd;
|
|
target_desired_distance = p_dd;
|
|
}
|
|
}
|
|
@@ -181,10 +197,7 @@ real_t NavigationAgent3D::get_path_max_distance() {
|
|
|
|
|
|
void NavigationAgent3D::set_target_location(Vector3 p_location) {
|
|
void NavigationAgent3D::set_target_location(Vector3 p_location) {
|
|
target_location = p_location;
|
|
target_location = p_location;
|
|
- navigation_path.clear();
|
|
|
|
- target_reached = false;
|
|
|
|
- navigation_finished = false;
|
|
|
|
- update_frame_id = 0;
|
|
|
|
|
|
+ _request_repath();
|
|
}
|
|
}
|
|
|
|
|
|
Vector3 NavigationAgent3D::get_target_location() const {
|
|
Vector3 NavigationAgent3D::get_target_location() const {
|
|
@@ -294,7 +307,7 @@ void NavigationAgent3D::update_navigation() {
|
|
}
|
|
}
|
|
|
|
|
|
if (reload_path) {
|
|
if (reload_path) {
|
|
- navigation_path = NavigationServer3D::get_singleton()->map_get_path(agent_parent->get_world_3d()->get_navigation_map(), o, target_location, true);
|
|
|
|
|
|
+ navigation_path = NavigationServer3D::get_singleton()->map_get_path(agent_parent->get_world_3d()->get_navigation_map(), o, target_location, true, navigable_layers);
|
|
navigation_finished = false;
|
|
navigation_finished = false;
|
|
nav_path_index = 0;
|
|
nav_path_index = 0;
|
|
emit_signal(SNAME("path_changed"));
|
|
emit_signal(SNAME("path_changed"));
|
|
@@ -320,6 +333,13 @@ void NavigationAgent3D::update_navigation() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void NavigationAgent3D::_request_repath() {
|
|
|
|
+ navigation_path.clear();
|
|
|
|
+ target_reached = false;
|
|
|
|
+ navigation_finished = false;
|
|
|
|
+ update_frame_id = 0;
|
|
|
|
+}
|
|
|
|
+
|
|
void NavigationAgent3D::_check_distance_to_target() {
|
|
void NavigationAgent3D::_check_distance_to_target() {
|
|
if (!target_reached) {
|
|
if (!target_reached) {
|
|
if (distance_to_target() < target_desired_distance) {
|
|
if (distance_to_target() < target_desired_distance) {
|