mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 11:56:49 +01:00
Backported from godot4: Tweak NavigationAgent2D defaults
Tweaks default values for NavigationAgent2D to work better out of the box within a new 2D project using default resolution.
- smix8
594ffd2200
This commit is contained in:
parent
d2e7ced27b
commit
935ed3c807
@ -180,7 +180,7 @@
|
||||
<member name="max_neighbors" type="int" setter="set_max_neighbors" getter="get_max_neighbors" default="10">
|
||||
The maximum number of neighbors for the agent to consider.
|
||||
</member>
|
||||
<member name="max_speed" type="float" setter="set_max_speed" getter="get_max_speed" default="200.0">
|
||||
<member name="max_speed" type="float" setter="set_max_speed" getter="get_max_speed" default="100.0">
|
||||
The maximum speed that an agent can move.
|
||||
</member>
|
||||
<member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1">
|
||||
@ -189,10 +189,10 @@
|
||||
<member name="neighbor_distance" type="float" setter="set_neighbor_distance" getter="get_neighbor_distance" default="500.0">
|
||||
The distance to search for other agents.
|
||||
</member>
|
||||
<member name="path_desired_distance" type="float" setter="set_path_desired_distance" getter="get_path_desired_distance" default="1.0">
|
||||
<member name="path_desired_distance" type="float" setter="set_path_desired_distance" getter="get_path_desired_distance" default="20.0">
|
||||
The distance threshold before a path point is considered to be reached. This will allow an agent to not have to hit a path point on the path exactly, but in the area. If this value is set to high the NavigationAgent will skip points on the path which can lead to leaving the navigation mesh. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the next point on each physics frame update.
|
||||
</member>
|
||||
<member name="path_max_distance" type="float" setter="set_path_max_distance" getter="get_path_max_distance" default="3.0">
|
||||
<member name="path_max_distance" type="float" setter="set_path_max_distance" getter="get_path_max_distance" default="100.0">
|
||||
The maximum distance the agent is allowed away from the ideal path to the final position. This can happen due to trying to avoid collisions. When the maximum distance is exceeded, it recalculates the ideal path.
|
||||
</member>
|
||||
<member name="path_metadata_flags" type="int" setter="set_path_metadata_flags" getter="get_path_metadata_flags" default="7">
|
||||
@ -202,7 +202,7 @@
|
||||
The radius of the avoidance agent. This is the "body" of the avoidance agent and not the avoidance maneuver starting radius (which is controlled by [member neighbor_distance]).
|
||||
Does not affect normal pathfinding. To change an actor's pathfinding radius bake [NavigationMesh] resources with a different [member NavigationMesh.agent_radius] property and use different navigation maps for each actor size.
|
||||
</member>
|
||||
<member name="target_desired_distance" type="float" setter="set_target_desired_distance" getter="get_target_desired_distance" default="1.0">
|
||||
<member name="target_desired_distance" type="float" setter="set_target_desired_distance" getter="get_target_desired_distance" default="10.0">
|
||||
The distance threshold before the final target point is considered to be reached. This will allow an agent to not have to hit the point of the final target exactly, but only the area. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the final target point on each physics frame update.
|
||||
</member>
|
||||
<member name="target_position" type="Vector2" setter="set_target_position" getter="get_target_position" default="Vector2( 0, 0 )">
|
||||
|
@ -120,9 +120,9 @@ void NavigationAgent2D::_bind_methods() {
|
||||
|
||||
ADD_GROUP("Pathfinding", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "target_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_target_position", "get_target_position");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "path_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01"), "set_path_desired_distance", "get_path_desired_distance");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01"), "set_target_desired_distance", "get_target_desired_distance");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "path_max_distance", PROPERTY_HINT_RANGE, "10,100,1"), "set_path_max_distance", "get_path_max_distance");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "path_desired_distance", PROPERTY_HINT_RANGE, "0.1,1000,0.01,suffix:px"), "set_path_desired_distance", "get_path_desired_distance");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,1000,0.01,suffix:px"), "set_target_desired_distance", "get_target_desired_distance");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "path_max_distance", PROPERTY_HINT_RANGE, "10,1000,1,suffix:px"), "set_path_max_distance", "get_path_max_distance");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_2D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "path_metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_path_metadata_flags", "get_path_metadata_flags");
|
||||
|
||||
@ -134,7 +134,7 @@ void NavigationAgent2D::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_neighbors", PROPERTY_HINT_RANGE, "1,10000,1,or_greater"), "set_max_neighbors", "get_max_neighbors");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_horizon_agents", PROPERTY_HINT_RANGE, "0.0,10,0.01,or_greater,suffix:s"), "set_time_horizon_agents", "get_time_horizon_agents");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_horizon_obstacles", PROPERTY_HINT_RANGE, "0.0,10,0.01,or_greater,suffix:s"), "set_time_horizon_obstacles", "get_time_horizon_obstacles");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_speed", PROPERTY_HINT_RANGE, "0.01,100000,0.01,or_greater,suffix:px/s"), "set_max_speed", "get_max_speed");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_speed", PROPERTY_HINT_RANGE, "0.01,10000,0.01,or_greater,suffix:px/s"), "set_max_speed", "get_max_speed");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "avoidance_layers", PROPERTY_HINT_LAYERS_AVOIDANCE), "set_avoidance_layers", "get_avoidance_layers");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "avoidance_mask", PROPERTY_HINT_LAYERS_AVOIDANCE), "set_avoidance_mask", "get_avoidance_mask");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "avoidance_priority", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_avoidance_priority", "get_avoidance_priority");
|
||||
@ -285,20 +285,19 @@ NavigationAgent2D::NavigationAgent2D() {
|
||||
navigation_layers = 1;
|
||||
path_metadata_flags = NavigationPathQueryParameters2D::PATH_METADATA_INCLUDE_ALL;
|
||||
|
||||
path_desired_distance = 1.0;
|
||||
target_desired_distance = 1.0;
|
||||
path_max_distance = 3.0;
|
||||
path_desired_distance = 20.0;
|
||||
target_desired_distance = 10.0;
|
||||
radius = 10.0;
|
||||
neighbor_distance = 500.0;
|
||||
max_neighbors = 10;
|
||||
time_horizon_agents = 1.0;
|
||||
time_horizon_obstacles = 0;
|
||||
max_speed = 100.0;
|
||||
path_max_distance = 100.0;
|
||||
|
||||
velocity_submitted = false;
|
||||
target_reached = false;
|
||||
navigation_finished = true;
|
||||
agent = Navigation2DServer::get_singleton()->agent_create();
|
||||
|
||||
set_neighbor_distance(500.0);
|
||||
set_max_neighbors(10);
|
||||
set_time_horizon_agents(1.0);
|
||||
set_time_horizon_obstacles(0.0);
|
||||
set_radius(10.0);
|
||||
set_max_speed(200.0);
|
||||
|
||||
velocity_forced_submitted = false;
|
||||
target_position_submitted = false;
|
||||
@ -306,9 +305,23 @@ NavigationAgent2D::NavigationAgent2D() {
|
||||
nav_path_index = 0;
|
||||
update_frame_id = 0;
|
||||
|
||||
agent = Navigation2DServer::get_singleton()->agent_create();
|
||||
|
||||
Navigation2DServer::get_singleton()->agent_set_neighbor_distance(agent, neighbor_distance);
|
||||
Navigation2DServer::get_singleton()->agent_set_max_neighbors(agent, max_neighbors);
|
||||
Navigation2DServer::get_singleton()->agent_set_time_horizon_agents(agent, time_horizon_agents);
|
||||
Navigation2DServer::get_singleton()->agent_set_time_horizon_obstacles(agent, time_horizon_obstacles);
|
||||
Navigation2DServer::get_singleton()->agent_set_radius(agent, radius);
|
||||
Navigation2DServer::get_singleton()->agent_set_max_speed(agent, max_speed);
|
||||
|
||||
navigation_query.instance();
|
||||
navigation_result.instance();
|
||||
|
||||
set_avoidance_layers(avoidance_layers);
|
||||
set_avoidance_mask(avoidance_mask);
|
||||
set_avoidance_priority(avoidance_priority);
|
||||
set_avoidance_enabled(avoidance_enabled);
|
||||
|
||||
debug_enabled = false;
|
||||
debug_path_dirty = true;
|
||||
debug_path_custom_point_size = 4.0;
|
||||
@ -319,11 +332,6 @@ NavigationAgent2D::NavigationAgent2D() {
|
||||
#ifdef DEBUG_ENABLED
|
||||
Navigation2DServer::get_singleton()->connect("navigation_debug_changed", this, "_navigation_debug_changed");
|
||||
#endif // DEBUG_ENABLED
|
||||
|
||||
set_avoidance_layers(avoidance_layers);
|
||||
set_avoidance_mask(avoidance_mask);
|
||||
set_avoidance_priority(avoidance_priority);
|
||||
set_avoidance_enabled(avoidance_enabled);
|
||||
}
|
||||
|
||||
NavigationAgent2D::~NavigationAgent2D() {
|
||||
|
@ -376,7 +376,7 @@ void NavigationPolygon::make_polygons_from_outlines() {
|
||||
if (tpart.ConvexPartition_HM(&in_poly, &out_poly) == 0) { //failed!
|
||||
ERR_PRINT("NavigationPolygon: Convex partition failed! Failed to convert outlines to a valid NavigationMesh."
|
||||
"\nNavigationPolygon outlines can not overlap vertices or edges inside same outline or with other outlines or have any intersections."
|
||||
"\nAdd the outmost and largest outline first. To add holes inside this outline add the smaller outlines with opposite winding order.");
|
||||
"\nAdd the outmost and largest outline first. To add holes inside this outline add the smaller outlines with same winding order.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user