Move the old comments from the steering ai module to the class doc xmls.

This commit is contained in:
Relintai 2023-01-14 14:31:39 +01:00
parent fc991ede18
commit 013fe0b1a2
59 changed files with 161 additions and 244 deletions

View File

@ -41,21 +41,9 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// A specialized steering agent that updates itself every frame so the user does
// not have to using a KinematicBody2D
// @category - Specialized agents
// SLIDE uses `move_and_slide`
// COLLIDE uses `move_and_collide`
// POSITION changes the `global_position` directly
// The KinematicBody2D to keep track of
// setget _set_body
// The type of movement the body executes
int movement_type; int movement_type;
Vector2 _last_position; Vector2 _last_position;
ObjectID _body_ref; ObjectID _body_ref;
// Moves the agent's `body` by target `acceleration`.
// @tags - virtual
}; };
#endif #endif

View File

@ -41,21 +41,9 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// A specialized steering agent that updates itself every frame so the user does
// not have to using a KinematicBody
// @category - Specialized agents
// SLIDE uses `move_and_slide`
// COLLIDE uses `move_and_collide`
// POSITION changes the global_position directly
// The KinematicBody to keep track of
// setget _set_body
// The type of movement the body executes
int movement_type; int movement_type;
Vector3 _last_position; Vector3 _last_position;
ObjectID _body_ref; ObjectID _body_ref;
// Moves the agent's `body` by target `acceleration`.
// @tags - virtual
}; };
#endif #endif

View File

@ -27,15 +27,8 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// A specialized steering agent that updates itself every frame so the user does
// not have to using a RigidBody2D
// @category - Specialized agents
// The RigidBody2D to keep track of
// setget _set_body
Vector2 _last_position; Vector2 _last_position;
ObjectID _body_ref; ObjectID _body_ref;
// Moves the agent's `body` by target `acceleration`.
// @tags - virtual
}; };
#endif #endif

View File

@ -27,15 +27,8 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// A specialized steering agent that updates itself every frame so the user does
// not have to using a RigidBody
// @category - Specialized agents
// The RigidBody to keep track of
// setget _set_body
Vector3 _last_position; Vector3 _last_position;
ObjectID _body_ref; ObjectID _body_ref;
// Moves the agent's `body` by target `acceleration`.
// @tags - virtual
}; };
#endif #endif

View File

@ -41,33 +41,13 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// A base class for a specialized steering agent that updates itself every frame
// so the user does not have to. All other specialized agents derive from this.
// @category - Specialized agents
// @tags - abstract
// If `true`, calculates linear and angular velocities based on the previous
// frame. When `false`, the user must keep those values updated.
bool calculate_velocities; bool calculate_velocities;
// If `true`, interpolates the current linear velocity towards 0 by the
// `linear_drag_percentage` value.
// Does not apply to `RigidBody` and `RigidBody2D` nodes.
bool apply_linear_drag; bool apply_linear_drag;
// If `true`, interpolates the current angular velocity towards 0 by the
// `angular_drag_percentage` value.
// Does not apply to `RigidBody` and `RigidBody2D` nodes.
bool apply_angular_drag; bool apply_angular_drag;
// The percentage between the current linear velocity and 0 to interpolate by if
// `apply_linear_drag` is true.
// Does not apply to `RigidBody` and `RigidBody2D` nodes.
float linear_drag_percentage; float linear_drag_percentage;
// The percentage between the current angular velocity and 0 to interpolate by if
// `apply_angular_drag` is true.
// Does not apply to `RigidBody` and `RigidBody2D` nodes.
float angular_drag_percentage; float angular_drag_percentage;
float last_orientation; float last_orientation;
bool applied_steering; bool applied_steering;
// Moves the agent's body by target `acceleration`.
// @tags - virtual
}; };
#endif #endif

View File

@ -34,17 +34,9 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Calculates acceleration to take an agent to its target's location. The
// calculation attempts to arrive with zero remaining velocity.
// @category - Individual behaviors
// Target agent to arrive to.
Ref<GSAIAgentLocation> target; Ref<GSAIAgentLocation> target;
// Distance from the target for the agent to be considered successfully
// arrived.
float arrival_tolerance; float arrival_tolerance;
// Distance from the target for the agent to begin slowing down.
float deceleration_radius; float deceleration_radius;
// Represents the time it takes to change acceleration.
float time_to_reach; float time_to_reach;
}; };

View File

@ -21,9 +21,6 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Steers the agent to avoid obstacles in its path. Approximates obstacles as
// spheres.
// @category - Group behaviors
Ref<GSAISteeringAgent> _first_neighbor; Ref<GSAISteeringAgent> _first_neighbor;
float _shortest_time; float _shortest_time;
float _first_minimum_separation; float _first_minimum_separation;

View File

@ -67,6 +67,7 @@ GSAIBlend::~GSAIBlend() {
void GSAIBlend::_bind_methods() { void GSAIBlend::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_behavior", "behavior", "weight"), &GSAIBlend::add_behavior); ClassDB::bind_method(D_METHOD("add_behavior", "behavior", "weight"), &GSAIBlend::add_behavior);
ClassDB::bind_method(D_METHOD("get_behavior", "index"), &GSAIBlend::get_behavior); ClassDB::bind_method(D_METHOD("get_behavior", "index"), &GSAIBlend::get_behavior);
ClassDB::bind_method(D_METHOD("get_behavior_weight", "index"), &GSAIBlend::get_behavior_weight);
ClassDB::bind_method(D_METHOD("remove_behavior", "index"), &GSAIBlend::remove_behavior); ClassDB::bind_method(D_METHOD("remove_behavior", "index"), &GSAIBlend::remove_behavior);
ClassDB::bind_method(D_METHOD("get_behaviour_count"), &GSAIBlend::get_behaviour_count); ClassDB::bind_method(D_METHOD("get_behaviour_count"), &GSAIBlend::get_behaviour_count);
ClassDB::bind_method(D_METHOD("get_accel"), &GSAIBlend::get_accel); ClassDB::bind_method(D_METHOD("get_accel"), &GSAIBlend::get_accel);

View File

@ -34,14 +34,8 @@ protected:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Blends multiple steering behaviors into one, and returns a weighted
// acceleration from their calculations.
// @category - Combination behaviors
Vector<GSAIBlendBehaviorEntry> _behaviors; Vector<GSAIBlendBehaviorEntry> _behaviors;
Ref<GSAITargetAcceleration> _accel; Ref<GSAITargetAcceleration> _accel;
// Appends a behavior to the internal array along with its `weight`.
// Returns the behavior at the specified `index`, or an empty `Dictionary` if
// none was found.
}; };
#endif #endif

View File

@ -21,9 +21,6 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Calculates an acceleration that attempts to move the agent towards the center
// of mass of the agents in the area defined by the `GSAIProximity`.
// @category - Group behaviors
Vector3 _center_of_mass; Vector3 _center_of_mass;
}; };

View File

@ -16,10 +16,6 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Calculates acceleration to take an agent away from where a target agent is
// moving.
// @category - Individual behaviors
}; };
#endif #endif

View File

@ -21,10 +21,6 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Calculates angular acceleration to rotate a target to face its target's
// position. The behavior attemps to arrive with zero remaining angular velocity.
// @category - Individual behaviors
}; };
#endif #endif

View File

@ -18,9 +18,6 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Calculates acceleration to take an agent directly away from a target agent.
// @category - Individual behaviors
}; };
#endif #endif

View File

@ -31,16 +31,9 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Produces a linear acceleration that moves the agent along the specified path.
// @category - Individual behaviors
// The path to follow and travel along.
Ref<GSAIPath> path; Ref<GSAIPath> path;
// The distance along the path to generate the next target position.
float path_offset; float path_offset;
// Whether to use `GSAIArrive` behavior on an open path.
bool is_arrive_enabled; bool is_arrive_enabled;
// The amount of time in the future to predict the owning agent's position along
// the path. Setting it to 0.0 will force non-predictive path following.
float prediction_time; float prediction_time;
}; };

View File

@ -18,10 +18,6 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Calculates an angular acceleration to match an agent's orientation to its
// direction of travel.
// @category - Individual behaviors
}; };
#endif #endif

View File

@ -38,21 +38,10 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Calculates an angular acceleration to match an agent's orientation to that of
// its target. Attempts to make the agent arrive with zero remaining angular
// velocity.
// @category - Individual behaviors
// The target orientation for the behavior to try and match rotations to.
Ref<GSAIAgentLocation> target; Ref<GSAIAgentLocation> target;
// The amount of distance in radians for the behavior to consider itself close
// enough to be matching the target agent's rotation.
float alignment_tolerance; float alignment_tolerance;
// The amount of distance in radians from the goal to start slowing down.
float deceleration_radius; float deceleration_radius;
// The amount of time to reach the target velocity
float time_to_reach; float time_to_reach;
// Whether to use the X and Z components instead of X and Y components when
// determining angles. X and Z should be used in 3D.
bool use_z; bool use_z;
}; };

View File

@ -28,18 +28,9 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Container for multiple behaviors that returns the result of the first child
// behavior with non-zero acceleration.
// @category - Combination behaviors
// If a behavior's acceleration is lower than this threshold, the container
// considers it has an acceleration of zero.
float zero_threshold; float zero_threshold;
// The index of the last behavior the container prioritized.
int _last_selected_index; int _last_selected_index;
Vector<Ref<GSAISteeringBehavior>> _behaviors; Vector<Ref<GSAISteeringBehavior>> _behaviors;
// Appends a steering behavior as a child of this container.
// Returns the behavior at the position in the pool referred to by `index`, or
// `null` if no behavior was found.
}; };
#endif #endif

View File

@ -29,13 +29,7 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Calculates an acceleration to make an agent intercept another based on the
// target agent's movement.
// @category - Individual behaviors
// The target agent that the behavior is trying to intercept.
Ref<GSAISteeringAgent> target; Ref<GSAISteeringAgent> target;
// The maximum amount of time in the future the behavior predicts the target's
// location.
float predict_time_max; float predict_time_max;
}; };

View File

@ -23,10 +23,6 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Calculates an acceleration to take an agent to a target agent's position
// directly.
// @category - Individual behaviors
// The target that the behavior aims to move the agent to.
Ref<GSAIAgentLocation> target; Ref<GSAIAgentLocation> target;
}; };

View File

@ -26,19 +26,8 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Calculates an acceleration that repels the agent from its neighbors in the
// given `GSAIProximity`.
//
// The acceleration is an average based on all neighbors, multiplied by a
// strength decreasing by the inverse square law in relation to distance, and it
// accumulates.
// @category - Group behaviors
// The coefficient to calculate how fast the separation strength decays with distance.
float decay_coefficient; float decay_coefficient;
Ref<GSAITargetAcceleration> acceleration; Ref<GSAITargetAcceleration> acceleration;
// Callback for the proximity to call when finding neighbors. Determines the amount of
// acceleration that `neighbor` imposes based on its distance from the owner agent.
// @tags - virtual
}; };
#endif #endif

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIAgentLocation" inherits="Reference" version="3.11"> <class name="GSAIAgentLocation" inherits="Reference" version="3.11">
<brief_description> <brief_description>
Represents an agent with only a location and an orientation.
</brief_description> </brief_description>
<description> <description>
Represents an agent with only a location and an orientation.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,8 +12,10 @@
</methods> </methods>
<members> <members>
<member name="orientation" type="float" setter="set_orientation" getter="get_orientation" default="0.0"> <member name="orientation" type="float" setter="set_orientation" getter="get_orientation" default="0.0">
The agent's orientation on its Y axis rotation.
</member> </member>
<member name="position" type="Vector3" setter="set_position" getter="get_position" default="Vector3( 0, 0, 0 )"> <member name="position" type="Vector3" setter="set_position" getter="get_position" default="Vector3( 0, 0, 0 )">
The agent's position in space.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIArrive" inherits="GSAISteeringBehavior" version="3.11"> <class name="GSAIArrive" inherits="GSAISteeringBehavior" version="3.11">
<brief_description> <brief_description>
Calculates acceleration to take an agent to its target's location. The calculation attempts to arrive with zero remaining velocity.
</brief_description> </brief_description>
<description> <description>
Calculates acceleration to take an agent to its target's location. The calculation attempts to arrive with zero remaining velocity.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -24,12 +26,16 @@
</methods> </methods>
<members> <members>
<member name="arrival_tolerance" type="float" setter="set_arrival_tolerance" getter="get_arrival_tolerance" default="0.0"> <member name="arrival_tolerance" type="float" setter="set_arrival_tolerance" getter="get_arrival_tolerance" default="0.0">
Distance from the target for the agent to be considered successfully arrived.
</member> </member>
<member name="deceleration_radius" type="float" setter="set_deceleration_radius" getter="get_deceleration_radius" default="0.0"> <member name="deceleration_radius" type="float" setter="set_deceleration_radius" getter="get_deceleration_radius" default="0.0">
Distance from the target for the agent to begin slowing down.
</member> </member>
<member name="target" type="GSAIAgentLocation" setter="set_target" getter="get_target"> <member name="target" type="GSAIAgentLocation" setter="set_target" getter="get_target">
Target agent to arrive to.
</member> </member>
<member name="time_to_reach" type="float" setter="set_time_to_reach" getter="get_time_to_reach" default="0.1"> <member name="time_to_reach" type="float" setter="set_time_to_reach" getter="get_time_to_reach" default="0.1">
Represents the time it takes to change acceleration.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIAvoidCollisions" inherits="GSAIGroupBehavior" version="3.11"> <class name="GSAIAvoidCollisions" inherits="GSAIGroupBehavior" version="3.11">
<brief_description> <brief_description>
Steers the agent to avoid obstacles in its path. Approximates obstacles as spheres.
</brief_description> </brief_description>
<description> <description>
Steers the agent to avoid obstacles in its path. Approximates obstacles as spheres.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIBlend" inherits="GSAISteeringBehavior" version="3.11"> <class name="GSAIBlend" inherits="GSAISteeringBehavior" version="3.11">
<brief_description> <brief_description>
Blends multiple steering behaviors into one, and returns a weighted acceleration from their calculations.
</brief_description> </brief_description>
<description> <description>
Blends multiple steering behaviors into one, and returns a weighted acceleration from their calculations.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -12,28 +14,40 @@
<argument index="0" name="behavior" type="GSAISteeringBehavior" /> <argument index="0" name="behavior" type="GSAISteeringBehavior" />
<argument index="1" name="weight" type="float" /> <argument index="1" name="weight" type="float" />
<description> <description>
Appends a behavior to the internal array along with its weight.
</description> </description>
</method> </method>
<method name="get_accel"> <method name="get_accel">
<return type="GSAITargetAcceleration" /> <return type="GSAITargetAcceleration" />
<description> <description>
Returns the internal GSAITargetAcceleration.
</description> </description>
</method> </method>
<method name="get_behavior"> <method name="get_behavior">
<return type="GSAISteeringBehavior" /> <return type="GSAISteeringBehavior" />
<argument index="0" name="index" type="int" /> <argument index="0" name="index" type="int" />
<description> <description>
Returns the behavior at the specified index, or null if none was found.
</description>
</method>
<method name="get_behavior_weight">
<return type="float" />
<argument index="0" name="index" type="int" />
<description>
Returns the behavior's weight at the specified index, or null if none was found.
</description> </description>
</method> </method>
<method name="get_behaviour_count"> <method name="get_behaviour_count">
<return type="int" /> <return type="int" />
<description> <description>
Returns how many behaviors are added.
</description> </description>
</method> </method>
<method name="remove_behavior"> <method name="remove_behavior">
<return type="void" /> <return type="void" />
<argument index="0" name="index" type="int" /> <argument index="0" name="index" type="int" />
<description> <description>
Removed the behavior at the specified index.
</description> </description>
</method> </method>
</methods> </methods>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAICohesion" inherits="GSAIGroupBehavior" version="3.11"> <class name="GSAICohesion" inherits="GSAIGroupBehavior" version="3.11">
<brief_description> <brief_description>
Calculates an acceleration that attempts to move the agent towards the center of mass of the agents in the area defined by the GSAIProximity.
</brief_description> </brief_description>
<description> <description>
Calculates an acceleration that attempts to move the agent towards the center of mass of the agents in the area defined by the GSAIProximity.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIEvade" inherits="GSAIPursue" version="3.11"> <class name="GSAIEvade" inherits="GSAIPursue" version="3.11">
<brief_description> <brief_description>
Calculates acceleration to take an agent away from where a target agent is moving.
</brief_description> </brief_description>
<description> <description>
Calculates acceleration to take an agent away from where a target agent is moving.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIFace" inherits="GSAIMatchOrientation" version="3.11"> <class name="GSAIFace" inherits="GSAIMatchOrientation" version="3.11">
<brief_description> <brief_description>
Calculates angular acceleration to rotate a target to face its target's position. The behavior attemps to arrive with zero remaining angular velocity.
</brief_description> </brief_description>
<description> <description>
Calculates angular acceleration to rotate a target to face its target's position. The behavior attemps to arrive with zero remaining angular velocity.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIFlee" inherits="GSAISeek" version="3.11"> <class name="GSAIFlee" inherits="GSAISeek" version="3.11">
<brief_description> <brief_description>
Calculates acceleration to take an agent directly away from a target agent.
</brief_description> </brief_description>
<description> <description>
Calculates acceleration to take an agent directly away from a target agent.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIFollowPath" inherits="GSAIArrive" version="3.11"> <class name="GSAIFollowPath" inherits="GSAIArrive" version="3.11">
<brief_description> <brief_description>
Produces a linear acceleration that moves the agent along the specified path.
</brief_description> </brief_description>
<description> <description>
Produces a linear acceleration that moves the agent along the specified path.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,12 +12,16 @@
</methods> </methods>
<members> <members>
<member name="is_arrive_enabled" type="bool" setter="set_is_arrive_enabled" getter="get_is_arrive_enabled" default="true"> <member name="is_arrive_enabled" type="bool" setter="set_is_arrive_enabled" getter="get_is_arrive_enabled" default="true">
Whether to use GSAIArrive behavior on an open path.
</member> </member>
<member name="path" type="GSAIPath" setter="set_path" getter="get_path"> <member name="path" type="GSAIPath" setter="set_path" getter="get_path">
The path to follow and travel along.
</member> </member>
<member name="path_offset" type="float" setter="set_path_offset" getter="get_path_offset" default="0.0"> <member name="path_offset" type="float" setter="set_path_offset" getter="get_path_offset" default="0.0">
The distance along the path to generate the next target position.
</member> </member>
<member name="prediction_time" type="float" setter="set_prediction_time" getter="get_prediction_time" default="0.0"> <member name="prediction_time" type="float" setter="set_prediction_time" getter="get_prediction_time" default="0.0">
The amount of time in the future to predict the owning agent's position along the path. Setting it to 0.0 will force non-predictive path following.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIGroupBehavior" inherits="GSAISteeringBehavior" version="3.11"> <class name="GSAIGroupBehavior" inherits="GSAISteeringBehavior" version="3.11">
<brief_description> <brief_description>
Base type for group-based steering behaviors.
</brief_description> </brief_description>
<description> <description>
Base type for group-based steering behaviors.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -16,8 +18,10 @@
</methods> </methods>
<members> <members>
<member name="_callback" type="FuncRef" setter="set_callback" getter="get_callback"> <member name="_callback" type="FuncRef" setter="set_callback" getter="get_callback">
Internal callback for the behavior to define whether or not a member is relevant
</member> </member>
<member name="proximity" type="GSAIProximity" setter="set_proximity" getter="get_proximity"> <member name="proximity" type="GSAIProximity" setter="set_proximity" getter="get_proximity">
Container to find neighbors of the agent and calculate group behavior.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIInfiniteProximity" inherits="GSAIProximity" version="3.11"> <class name="GSAIInfiniteProximity" inherits="GSAIProximity" version="3.11">
<brief_description> <brief_description>
Determines any agent that is in the specified list as being neighbors with the owner agent, regardless of distance.
</brief_description> </brief_description>
<description> <description>
Determines any agent that is in the specified list as being neighbors with the owner agent, regardless of distance.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIKinematicBody2DAgent" inherits="GSAISpecializedAgent" version="3.11"> <class name="GSAIKinematicBody2DAgent" inherits="GSAISpecializedAgent" version="3.11">
<brief_description> <brief_description>
A specialized steering agent that updates itself every frame so the user does not have to using a KinematicBody2D.
</brief_description> </brief_description>
<description> <description>
A specialized steering agent that updates itself every frame so the user does not have to using a KinematicBody2D.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,8 +12,12 @@
</methods> </methods>
<members> <members>
<member name="body" type="KinematicBody2D" setter="set_body" getter="get_body"> <member name="body" type="KinematicBody2D" setter="set_body" getter="get_body">
The KinematicBody2D to keep track of.
</member> </member>
<member name="movement_type" type="int" setter="set_movement_type" getter="get_movement_type" default="0"> <member name="movement_type" type="int" setter="set_movement_type" getter="get_movement_type" default="0">
SLIDE uses move_and_slide.
COLLIDE uses move_and_collide.
POSITION changes the global_position directly.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIKinematicBody3DAgent" inherits="GSAISpecializedAgent" version="3.11"> <class name="GSAIKinematicBody3DAgent" inherits="GSAISpecializedAgent" version="3.11">
<brief_description> <brief_description>
A specialized steering agent that updates itself every frame so the user does not have to using a KinematicBody.
</brief_description> </brief_description>
<description> <description>
A specialized steering agent that updates itself every frame so the user does not have to using a KinematicBody.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,8 +12,12 @@
</methods> </methods>
<members> <members>
<member name="body" type="KinematicBody" setter="set_body" getter="get_body"> <member name="body" type="KinematicBody" setter="set_body" getter="get_body">
The KinematicBody to keep track of.
</member> </member>
<member name="movement_type" type="int" setter="set_movement_type" getter="get_movement_type" default="0"> <member name="movement_type" type="int" setter="set_movement_type" getter="get_movement_type" default="0">
SLIDE uses move_and_slide.
COLLIDE uses move_and_collide.
POSITION changes the global_position directly.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAILookWhereYouGo" inherits="GSAIMatchOrientation" version="3.11"> <class name="GSAILookWhereYouGo" inherits="GSAIMatchOrientation" version="3.11">
<brief_description> <brief_description>
Calculates an angular acceleration to match an agent's orientation to its direction of travel.
</brief_description> </brief_description>
<description> <description>
Calculates an angular acceleration to match an agent's orientation to its direction of travel.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIMatchOrientation" inherits="GSAISteeringBehavior" version="3.11"> <class name="GSAIMatchOrientation" inherits="GSAISteeringBehavior" version="3.11">
<brief_description> <brief_description>
Calculates an angular acceleration to match an agent's orientation to that of its target. Attempts to make the agent arrive with zero remaining angular velocity.
</brief_description> </brief_description>
<description> <description>
Calculates an angular acceleration to match an agent's orientation to that of its target. Attempts to make the agent arrive with zero remaining angular velocity.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -24,14 +26,19 @@
</methods> </methods>
<members> <members>
<member name="alignment_tolerance" type="float" setter="set_alignment_tolerance" getter="get_alignment_tolerance" default="0.0"> <member name="alignment_tolerance" type="float" setter="set_alignment_tolerance" getter="get_alignment_tolerance" default="0.0">
The amount of distance in radians for the behavior to consider itself close enough to be matching the target agent's rotation.
</member> </member>
<member name="deceleration_radius" type="float" setter="set_deceleration_radius" getter="get_deceleration_radius" default="0.0"> <member name="deceleration_radius" type="float" setter="set_deceleration_radius" getter="get_deceleration_radius" default="0.0">
The amount of distance in radians from the goal to start slowing down.
</member> </member>
<member name="target" type="GSAIAgentLocation" setter="set_target" getter="get_target"> <member name="target" type="GSAIAgentLocation" setter="set_target" getter="get_target">
The target orientation for the behavior to try and match rotations to.
</member> </member>
<member name="time_to_reach" type="float" setter="set_time_to_reach" getter="get_time_to_reach" default="0.1"> <member name="time_to_reach" type="float" setter="set_time_to_reach" getter="get_time_to_reach" default="0.1">
The amount of time to reach the target velocity
</member> </member>
<member name="use_z" type="bool" setter="set_use_z" getter="get_use_z" default="false"> <member name="use_z" type="bool" setter="set_use_z" getter="get_use_z" default="false">
Whether to use the X and Z components instead of X and Y components when determining angles. X and Z should be used in 3D.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIPath" inherits="Reference" version="3.11"> <class name="GSAIPath" inherits="Reference" version="3.11">
<brief_description> <brief_description>
Represents a path made up of Vector3 waypoints, split into segments path follow behaviors can use.
</brief_description> </brief_description>
<description> <description>
Represents a path made up of Vector3 waypoints, split into segments path follow behaviors can use.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -17,22 +19,26 @@
<return type="Vector3" /> <return type="Vector3" />
<argument index="0" name="target_distance" type="float" /> <argument index="0" name="target_distance" type="float" />
<description> <description>
Calculates a target position from the path's starting point based on the target_distance.
</description> </description>
</method> </method>
<method name="create_path"> <method name="create_path">
<return type="void" /> <return type="void" />
<argument index="0" name="waypoints" type="PoolVector3Array" /> <argument index="0" name="waypoints" type="PoolVector3Array" />
<description> <description>
Creates a path from a list of waypoints.
</description> </description>
</method> </method>
<method name="get_end_point"> <method name="get_end_point">
<return type="Vector3" /> <return type="Vector3" />
<description> <description>
Returns the position of the last point on the path.
</description> </description>
</method> </method>
<method name="get_start_point"> <method name="get_start_point">
<return type="Vector3" /> <return type="Vector3" />
<description> <description>
Returns the position of the first point on the path.
</description> </description>
</method> </method>
<method name="initialize"> <method name="initialize">
@ -45,8 +51,10 @@
</methods> </methods>
<members> <members>
<member name="is_open" type="bool" setter="set_is_open" getter="get_is_open" default="false"> <member name="is_open" type="bool" setter="set_is_open" getter="get_is_open" default="false">
If false, the path loops.
</member> </member>
<member name="length" type="float" setter="set_length" getter="get_length" default="0.0"> <member name="length" type="float" setter="set_length" getter="get_length" default="0.0">
Total length of the path.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIPriority" inherits="GSAISteeringBehavior" version="3.11"> <class name="GSAIPriority" inherits="GSAISteeringBehavior" version="3.11">
<brief_description> <brief_description>
Container for multiple behaviors that returns the result of the first child behavior with non-zero acceleration.
</brief_description> </brief_description>
<description> <description>
Container for multiple behaviors that returns the result of the first child behavior with non-zero acceleration.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -11,28 +13,33 @@
<return type="void" /> <return type="void" />
<argument index="0" name="behavior" type="GSAISteeringBehavior" /> <argument index="0" name="behavior" type="GSAISteeringBehavior" />
<description> <description>
Appends a steering behavior as a child of this container.
</description> </description>
</method> </method>
<method name="get_behavior"> <method name="get_behavior">
<return type="GSAISteeringBehavior" /> <return type="GSAISteeringBehavior" />
<argument index="0" name="index" type="int" /> <argument index="0" name="index" type="int" />
<description> <description>
Returns the behavior at the position in the pool referred to by index, or null if no behavior was found.
</description> </description>
</method> </method>
<method name="get_behaviour_count"> <method name="get_behaviour_count">
<return type="int" /> <return type="int" />
<description> <description>
Returns how many behaviors are added.
</description> </description>
</method> </method>
<method name="remove_behavior"> <method name="remove_behavior">
<return type="void" /> <return type="void" />
<argument index="0" name="index" type="int" /> <argument index="0" name="index" type="int" />
<description> <description>
Removed the behavior at the position in the pool referred to by index.
</description> </description>
</method> </method>
</methods> </methods>
<members> <members>
<member name="zero_threshold" type="float" setter="set_zero_threshold" getter="get_zero_threshold" default="0.0"> <member name="zero_threshold" type="float" setter="set_zero_threshold" getter="get_zero_threshold" default="0.0">
If a behavior's acceleration is lower than this threshold, the container considers it has an acceleration of zero.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIProximity" inherits="Reference" version="3.11"> <class name="GSAIProximity" inherits="Reference" version="3.11">
<brief_description> <brief_description>
Base container type that stores data to find the neighbors of an agent.
</brief_description> </brief_description>
<description> <description>
Base container type that stores data to find the neighbors of an agent.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -11,19 +13,25 @@
<return type="int" /> <return type="int" />
<argument index="0" name="callback" type="FuncRef" /> <argument index="0" name="callback" type="FuncRef" />
<description> <description>
Returns a number of neighbors based on a `callback` function.
_find_neighbors calls callback for each agent in the agents array and adds one to the count if its callback returns true.
</description> </description>
</method> </method>
<method name="find_neighbors"> <method name="find_neighbors">
<return type="int" /> <return type="int" />
<argument index="0" name="callback" type="FuncRef" /> <argument index="0" name="callback" type="FuncRef" />
<description> <description>
Returns a number of neighbors based on a `callback` function.
_find_neighbors calls callback for each agent in the agents array and adds one to the count if its callback returns true.
</description> </description>
</method> </method>
</methods> </methods>
<members> <members>
<member name="agent" type="GSAISteeringAgent" setter="set_agent" getter="get_agent"> <member name="agent" type="GSAISteeringAgent" setter="set_agent" getter="get_agent">
The owning agent whose neighbors are found in the group
</member> </member>
<member name="agents" type="Array" setter="set_agents" getter="get_agents" default="[ ]"> <member name="agents" type="Array" setter="set_agents" getter="get_agents" default="[ ]">
The agents who are part of this group and could be potential neighbors
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIPursue" inherits="GSAISteeringBehavior" version="3.11"> <class name="GSAIPursue" inherits="GSAISteeringBehavior" version="3.11">
<brief_description> <brief_description>
Calculates an acceleration to make an agent intercept another based on the target agent's movement.
</brief_description> </brief_description>
<description> <description>
Calculates an acceleration to make an agent intercept another based on the target agent's movement.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -20,8 +22,10 @@
</methods> </methods>
<members> <members>
<member name="predict_time_max" type="float" setter="set_predict_time_max" getter="get_predict_time_max" default="1.0"> <member name="predict_time_max" type="float" setter="set_predict_time_max" getter="get_predict_time_max" default="1.0">
The maximum amount of time in the future the behavior predicts the target's location.
</member> </member>
<member name="target" type="GSAISteeringAgent" setter="set_target" getter="get_target"> <member name="target" type="GSAISteeringAgent" setter="set_target" getter="get_target">
The target agent that the behavior is trying to intercept.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIRadiusProximity" inherits="GSAIProximity" version="3.11"> <class name="GSAIRadiusProximity" inherits="GSAIProximity" version="3.11">
<brief_description> <brief_description>
Determines any agent that is in the specified list as being neighbors with the owner agent if they lie within the specified radius.
</brief_description> </brief_description>
<description> <description>
Determines any agent that is in the specified list as being neighbors with the owner agent if they lie within the specified radius.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,6 +12,7 @@
</methods> </methods>
<members> <members>
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="0.0"> <member name="radius" type="float" setter="set_radius" getter="get_radius" default="0.0">
The radius around the owning agent to find neighbors in
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIRigidBody2DAgent" inherits="GSAISpecializedAgent" version="3.11"> <class name="GSAIRigidBody2DAgent" inherits="GSAISpecializedAgent" version="3.11">
<brief_description> <brief_description>
A specialized steering agent that updates itself every frame so the user does not have to using a RigidBody2D.
</brief_description> </brief_description>
<description> <description>
A specialized steering agent that updates itself every frame so the user does not have to using a RigidBody2D.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,6 +12,7 @@
</methods> </methods>
<members> <members>
<member name="body" type="RigidBody2D" setter="set_body" getter="get_body"> <member name="body" type="RigidBody2D" setter="set_body" getter="get_body">
The RigidBody2D to keep track of.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIRigidBody3DAgent" inherits="GSAISpecializedAgent" version="3.11"> <class name="GSAIRigidBody3DAgent" inherits="GSAISpecializedAgent" version="3.11">
<brief_description> <brief_description>
A specialized steering agent that updates itself every frame so the user does not have to using a RigidBody
</brief_description> </brief_description>
<description> <description>
A specialized steering agent that updates itself every frame so the user does not have to using a RigidBody
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,6 +12,7 @@
</methods> </methods>
<members> <members>
<member name="body" type="RigidBody" setter="set_body" getter="get_body"> <member name="body" type="RigidBody" setter="set_body" getter="get_body">
The RigidBody to keep track of.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAISeek" inherits="GSAISteeringBehavior" version="3.11"> <class name="GSAISeek" inherits="GSAISteeringBehavior" version="3.11">
<brief_description> <brief_description>
Calculates an acceleration to take an agent to a target agent's position directly.
</brief_description> </brief_description>
<description> <description>
Calculates an acceleration to take an agent to a target agent's position directly.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,6 +12,7 @@
</methods> </methods>
<members> <members>
<member name="target" type="GSAIAgentLocation" setter="set_target" getter="get_target"> <member name="target" type="GSAIAgentLocation" setter="set_target" getter="get_target">
The target that the behavior aims to move the agent to.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAISeparation" inherits="GSAIGroupBehavior" version="3.11"> <class name="GSAISeparation" inherits="GSAIGroupBehavior" version="3.11">
<brief_description> <brief_description>
Calculates an acceleration that repels the agent from its neighbors in the given GSAIProximity.
</brief_description> </brief_description>
<description> <description>
Calculates an acceleration that repels the agent from its neighbors in the given GSAIProximity.
_callback is the callback for the proximity to call when finding neighbors. Determines the amount of acceleration that neighbor imposes based on its distance from the owner agent.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -11,8 +14,10 @@
<members> <members>
<member name="_callback" type="FuncRef" setter="set_callback" getter="get_callback" overrides="GSAIGroupBehavior" /> <member name="_callback" type="FuncRef" setter="set_callback" getter="get_callback" overrides="GSAIGroupBehavior" />
<member name="acceleration" type="GSAITargetAcceleration" setter="set_acceleration" getter="get_acceleration"> <member name="acceleration" type="GSAITargetAcceleration" setter="set_acceleration" getter="get_acceleration">
The acceleration is an average based on all neighbors, multiplied by a strength decreasing by the inverse square law in relation to distance, and it accumulates.
</member> </member>
<member name="decay_coefficient" type="float" setter="set_decay_coefficient" getter="get_decay_coefficient" default="1.0"> <member name="decay_coefficient" type="float" setter="set_decay_coefficient" getter="get_decay_coefficient" default="1.0">
The coefficient to calculate how fast the separation strength decays with distance.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAISpecializedAgent" inherits="GSAISteeringAgent" version="3.11"> <class name="GSAISpecializedAgent" inherits="GSAISteeringAgent" version="3.11">
<brief_description> <brief_description>
A base class for a specialized steering agent that updates itself every frame so the user does not have to. All other specialized agents derive from this.
</brief_description> </brief_description>
<description> <description>
A base class for a specialized steering agent that updates itself every frame so the user does not have to. All other specialized agents derive from this.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -12,6 +14,7 @@
<argument index="0" name="acceleration" type="GSAITargetAcceleration" /> <argument index="0" name="acceleration" type="GSAITargetAcceleration" />
<argument index="1" name="delta" type="float" /> <argument index="1" name="delta" type="float" />
<description> <description>
Moves the agent's body by target acceleration.
</description> </description>
</method> </method>
<method name="apply_steering"> <method name="apply_steering">
@ -19,23 +22,29 @@
<argument index="0" name="acceleration" type="GSAITargetAcceleration" /> <argument index="0" name="acceleration" type="GSAITargetAcceleration" />
<argument index="1" name="delta" type="float" /> <argument index="1" name="delta" type="float" />
<description> <description>
Moves the agent's body by target acceleration.
</description> </description>
</method> </method>
</methods> </methods>
<members> <members>
<member name="angular_drag_percentage" type="float" setter="set_angular_drag_percentage" getter="get_angular_drag_percentage" default="0.0"> <member name="angular_drag_percentage" type="float" setter="set_angular_drag_percentage" getter="get_angular_drag_percentage" default="0.0">
The percentage between the current angular velocity and 0 to interpolate by if apply_angular_drag is true. Does not apply to RigidBody and RigidBody2D nodes.
</member> </member>
<member name="applied_steering" type="bool" setter="set_applied_steering" getter="get_applied_steering" default="false"> <member name="applied_steering" type="bool" setter="set_applied_steering" getter="get_applied_steering" default="false">
</member> </member>
<member name="apply_angular_drag" type="bool" setter="set_apply_angular_drag" getter="get_apply_angular_drag" default="true"> <member name="apply_angular_drag" type="bool" setter="set_apply_angular_drag" getter="get_apply_angular_drag" default="true">
If true, interpolates the current angular velocity towards 0 by the angular_drag_percentage value. Does not apply to RigidBody and RigidBody2D nodes.
</member> </member>
<member name="apply_linear_drag" type="bool" setter="set_apply_linear_drag" getter="get_apply_linear_drag" default="true"> <member name="apply_linear_drag" type="bool" setter="set_apply_linear_drag" getter="get_apply_linear_drag" default="true">
If true, interpolates the current linear velocity towards 0 by the linear_drag_percentage value. Does not apply to RigidBody and RigidBody2D nodes.
</member> </member>
<member name="calculate_velocities" type="bool" setter="set_calculate_velocities" getter="get_calculate_velocities" default="true"> <member name="calculate_velocities" type="bool" setter="set_calculate_velocities" getter="get_calculate_velocities" default="true">
If true, calculates linear and angular velocities based on the previous frame. When false, the user must keep those values updated.
</member> </member>
<member name="last_orientation" type="float" setter="set_last_orientation" getter="get_last_orientation" default="0.0"> <member name="last_orientation" type="float" setter="set_last_orientation" getter="get_last_orientation" default="0.0">
</member> </member>
<member name="linear_drag_percentage" type="float" setter="set_linear_drag_percentage" getter="get_linear_drag_percentage" default="0.0"> <member name="linear_drag_percentage" type="float" setter="set_linear_drag_percentage" getter="get_linear_drag_percentage" default="0.0">
The percentage between the current linear velocity and 0 to interpolate by if apply_linear_drag is true. Does not apply to RigidBody and RigidBody2D nodes.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAISteeringAgent" inherits="GSAIAgentLocation" version="3.11"> <class name="GSAISteeringAgent" inherits="GSAIAgentLocation" version="3.11">
<brief_description> <brief_description>
Adds velocity, speed, and size data to GSAIAgentLocation.
</brief_description> </brief_description>
<description> <description>
Adds velocity, speed, and size data to GSAIAgentLocation.
It is the character's responsibility to keep this information up to date for the steering toolkit to work correctly.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,22 +13,31 @@
</methods> </methods>
<members> <members>
<member name="angular_acceleration_max" type="float" setter="set_angular_acceleration_max" getter="get_angular_acceleration_max" default="0.0"> <member name="angular_acceleration_max" type="float" setter="set_angular_acceleration_max" getter="get_angular_acceleration_max" default="0.0">
The maximum amount of angular acceleration that any behavior can apply to an agent.
</member> </member>
<member name="angular_speed_max" type="float" setter="set_angular_speed_max" getter="get_angular_speed_max" default="0.0"> <member name="angular_speed_max" type="float" setter="set_angular_speed_max" getter="get_angular_speed_max" default="0.0">
The maximum amount of angular speed at which the agent can rotate.
</member> </member>
<member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity" default="0.0"> <member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity" default="0.0">
Current angular velocity of the agent.
</member> </member>
<member name="bounding_radius" type="float" setter="set_bounding_radius" getter="get_bounding_radius" default="0.0"> <member name="bounding_radius" type="float" setter="set_bounding_radius" getter="get_bounding_radius" default="0.0">
The radius of the sphere that approximates the agent's size in space.
</member> </member>
<member name="is_tagged" type="bool" setter="set_is_tagged" getter="get_is_tagged" default="false"> <member name="is_tagged" type="bool" setter="set_is_tagged" getter="get_is_tagged" default="false">
Used internally by group behaviors and proximities to mark the agent as already considered.
</member> </member>
<member name="linear_acceleration_max" type="float" setter="set_linear_acceleration_max" getter="get_linear_acceleration_max" default="0.0"> <member name="linear_acceleration_max" type="float" setter="set_linear_acceleration_max" getter="get_linear_acceleration_max" default="0.0">
The maximum amount of acceleration that any behavior can apply to the agent.
</member> </member>
<member name="linear_speed_max" type="float" setter="set_linear_speed_max" getter="get_linear_speed_max" default="0.0"> <member name="linear_speed_max" type="float" setter="set_linear_speed_max" getter="get_linear_speed_max" default="0.0">
The maximum speed at which the agent can move.
</member> </member>
<member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3( 0, 0, 0 )"> <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3( 0, 0, 0 )">
Current velocity of the agent.
</member> </member>
<member name="zero_linear_speed_threshold" type="float" setter="set_zero_linear_speed_threshold" getter="get_zero_linear_speed_threshold" default="0.01"> <member name="zero_linear_speed_threshold" type="float" setter="set_zero_linear_speed_threshold" getter="get_zero_linear_speed_threshold" default="0.01">
The amount of velocity to be considered effectively not moving.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAISteeringBehavior" inherits="Reference" version="3.11"> <class name="GSAISteeringBehavior" inherits="Reference" version="3.11">
<brief_description> <brief_description>
Base class for all steering behaviors.
</brief_description> </brief_description>
<description> <description>
Base class for all steering behaviors.
Steering behaviors calculate the linear and the angular acceleration to be to the agent that owns them.
Individual steering behaviors encapsulate the steering logic.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -11,19 +15,23 @@
<return type="void" /> <return type="void" />
<argument index="0" name="acceleration" type="GSAITargetAcceleration" /> <argument index="0" name="acceleration" type="GSAITargetAcceleration" />
<description> <description>
The calculate_steering function is the entry point for all behaviors. Sets the acceleration with the behavior's desired amount of acceleration.
</description> </description>
</method> </method>
<method name="calculate_steering"> <method name="calculate_steering">
<return type="void" /> <return type="void" />
<argument index="0" name="acceleration" type="GSAITargetAcceleration" /> <argument index="0" name="acceleration" type="GSAITargetAcceleration" />
The calculate_steering function is the entry point for all behaviors. Sets the acceleration with the behavior's desired amount of acceleration.
<description> <description>
</description> </description>
</method> </method>
</methods> </methods>
<members> <members>
<member name="agent" type="GSAISteeringAgent" setter="set_agent" getter="get_agent"> <member name="agent" type="GSAISteeringAgent" setter="set_agent" getter="get_agent">
The AI agent on which the steering behavior bases its calculations.
</member> </member>
<member name="is_enabled" type="bool" setter="set_is_enabled" getter="get_is_enabled" default="true"> <member name="is_enabled" type="bool" setter="set_is_enabled" getter="get_is_enabled" default="true">
If false, all calculations return zero amounts of acceleration.
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAITargetAcceleration" inherits="Reference" version="3.11"> <class name="GSAITargetAcceleration" inherits="Reference" version="3.11">
<brief_description> <brief_description>
A desired linear and angular amount of acceleration requested by the steering system.
</brief_description> </brief_description>
<description> <description>
A desired linear and angular amount of acceleration requested by the steering system.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -12,28 +14,34 @@
<argument index="0" name="accel" type="GSAITargetAcceleration" /> <argument index="0" name="accel" type="GSAITargetAcceleration" />
<argument index="1" name="scalar" type="float" /> <argument index="1" name="scalar" type="float" />
<description> <description>
Adds accel's components, multiplied by scalar, to this one.
</description> </description>
</method> </method>
<method name="get_magnitude"> <method name="get_magnitude">
<return type="float" /> <return type="float" />
<description> <description>
Returns the squared magnitude of the linear and angular components.
</description> </description>
</method> </method>
<method name="get_magnitude_squared"> <method name="get_magnitude_squared">
<return type="float" /> <return type="float" />
<description> <description>
Returns the squared magnitude of the linear and angular components.
</description> </description>
</method> </method>
<method name="set_zero"> <method name="set_zero">
<return type="void" /> <return type="void" />
<description> <description>
Sets the linear and angular components to 0.
</description> </description>
</method> </method>
</methods> </methods>
<members> <members>
<member name="angular" type="float" setter="set_angular" getter="get_angular" default="0.0"> <member name="angular" type="float" setter="set_angular" getter="get_angular" default="0.0">
Angular acceleration
</member> </member>
<member name="linear" type="Vector3" setter="set_linear" getter="get_linear" default="Vector3( 0, 0, 0 )"> <member name="linear" type="Vector3" setter="set_linear" getter="get_linear" default="Vector3( 0, 0, 0 )">
Linear acceleration
</member> </member>
</members> </members>
<constants> <constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIUtils" inherits="Object" version="3.11"> <class name="GSAIUtils" inherits="Object" version="3.11">
<brief_description> <brief_description>
Math and vector utility functions.
</brief_description> </brief_description>
<description> <description>
Math and vector utility functions.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -11,6 +13,7 @@
<return type="Vector2" /> <return type="Vector2" />
<argument index="0" name="angle" type="float" /> <argument index="0" name="angle" type="float" />
<description> <description>
Returns a directional vector from the given orientation angle. This assumes orientation for 2D agents or 3D agents that are upright and rotate around the Y axis.
</description> </description>
</method> </method>
<method name="clampedv3"> <method name="clampedv3">
@ -18,30 +21,35 @@
<argument index="0" name="vector" type="Vector3" /> <argument index="0" name="vector" type="Vector3" />
<argument index="1" name="limit" type="float" /> <argument index="1" name="limit" type="float" />
<description> <description>
Returns the vector with its length capped to limit.
</description> </description>
</method> </method>
<method name="to_vector2"> <method name="to_vector2">
<return type="Vector2" /> <return type="Vector2" />
<argument index="0" name="vector" type="Vector3" /> <argument index="0" name="vector" type="Vector3" />
<description> <description>
Returns a vector2 with vector's x and y components.
</description> </description>
</method> </method>
<method name="to_vector3"> <method name="to_vector3">
<return type="Vector3" /> <return type="Vector3" />
<argument index="0" name="vector" type="Vector2" /> <argument index="0" name="vector" type="Vector2" />
<description> <description>
Returns a vector3 with vector's x and y components and 0 in z.
</description> </description>
</method> </method>
<method name="vector2_to_angle"> <method name="vector2_to_angle">
<return type="float" /> <return type="float" />
<argument index="0" name="vector" type="Vector2" /> <argument index="0" name="vector" type="Vector2" />
<description> <description>
Returns an angle in radians between the positive X axis and the vector.
</description> </description>
</method> </method>
<method name="vector3_to_angle"> <method name="vector3_to_angle">
<return type="float" /> <return type="float" />
<argument index="0" name="vector" type="Vector3" /> <argument index="0" name="vector" type="Vector3" />
<description> <description>
Returns an angle in radians between the positive X axis and the vector. This assumes orientation for 3D agents that are upright and rotate around the Y axis.
</description> </description>
</method> </method>
</methods> </methods>

View File

@ -21,11 +21,7 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Represents an agent with only a location and an orientation.
// @category - Base types
// The agent's position in space.
Vector3 position; Vector3 position;
// The agent's orientation on its Y axis rotation.
float orientation; float orientation;
}; };

View File

@ -29,14 +29,8 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Base type for group-based steering behaviors.
// @category - Base types
// Container to find neighbors of the agent and calculate group behavior.
Ref<GSAIProximity> proximity; Ref<GSAIProximity> proximity;
Ref<FuncRef> _callback; Ref<FuncRef> _callback;
// Internal callback for the behavior to define whether or not a member is
// relevant
// @tags - virtual
}; };
#endif #endif

View File

@ -54,23 +54,13 @@ protected:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Represents a path made up of Vector3 waypoints, split into segments path
// follow behaviors can use.
// @category - Base types
// If `false`, the path loops.
bool is_open; bool is_open;
// Total length of the path.
float length; float length;
Vector<GSAISegment> _segments; Vector<GSAISegment> _segments;
Vector3 _nearest_point_on_segment; Vector3 _nearest_point_on_segment;
Vector3 _nearest_point_on_path; Vector3 _nearest_point_on_path;
// Creates a path from a list of waypoints.
// Calculates a target position from the path's starting point based on the `target_distance`.
// Returns the position of the first point on the path.
// Returns the position of the last point on the path.
// not exposed helper struct
}; };
#endif #endif

View File

@ -45,30 +45,14 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Adds velocity, speed, and size data to `GSAIAgentLocation`.
//
// It is the character's responsibility to keep this information up to date for
// the steering toolkit to work correctly.
// @category - Base types
// The amount of velocity to be considered effectively not moving.
float zero_linear_speed_threshold; float zero_linear_speed_threshold;
// The maximum speed at which the agent can move.
float linear_speed_max; float linear_speed_max;
// The maximum amount of acceleration that any behavior can apply to the agent.
float linear_acceleration_max; float linear_acceleration_max;
// The maximum amount of angular speed at which the agent can rotate.
float angular_speed_max; float angular_speed_max;
// The maximum amount of angular acceleration that any behavior can apply to an
// agent.
float angular_acceleration_max; float angular_acceleration_max;
// Current velocity of the agent.
Vector3 linear_velocity; Vector3 linear_velocity;
// Current angular velocity of the agent.
float angular_velocity; float angular_velocity;
// The radius of the sphere that approximates the agent's size in space.
float bounding_radius; float bounding_radius;
// Used internally by group behaviors and proximities to mark the agent as already
// considered.
bool is_tagged; bool is_tagged;
}; };

View File

@ -9,25 +9,16 @@
class GSAISteeringAgent; class GSAISteeringAgent;
class GSAITargetAcceleration; class GSAITargetAcceleration;
// Base class for all steering behaviors.
// Steering behaviors calculate the linear and the angular acceleration to be
// to the agent that owns them.
// Individual steering behaviors encapsulate the steering logic.
class GSAISteeringBehavior : public Reference { class GSAISteeringBehavior : public Reference {
GDCLASS(GSAISteeringBehavior, Reference); GDCLASS(GSAISteeringBehavior, Reference);
public: public:
// If `false`, all calculations return zero amounts of acceleration.
bool get_is_enabled() const; bool get_is_enabled() const;
void set_is_enabled(const bool val); void set_is_enabled(const bool val);
// The AI agent on which the steering behavior bases its calculations.
Ref<GSAISteeringAgent> get_agent(); Ref<GSAISteeringAgent> get_agent();
void set_agent(const Ref<GSAISteeringAgent> &val); void set_agent(const Ref<GSAISteeringAgent> &val);
// The `calculate_steering` function is the entry point for all behaviors.
// Sets the `acceleration` with the behavior's desired amount of acceleration.
void calculate_steering(Ref<GSAITargetAcceleration> acceleration); void calculate_steering(Ref<GSAITargetAcceleration> acceleration);
virtual void _calculate_steering(Ref<GSAITargetAcceleration> acceleration); virtual void _calculate_steering(Ref<GSAITargetAcceleration> acceleration);

View File

@ -5,8 +5,6 @@
#include "core/math/vector3.h" #include "core/math/vector3.h"
#include "core/object/reference.h" #include "core/object/reference.h"
// A desired linear and angular amount of acceleration requested by the steering system.
class GSAITargetAcceleration : public Reference { class GSAITargetAcceleration : public Reference {
GDCLASS(GSAITargetAcceleration, Reference); GDCLASS(GSAITargetAcceleration, Reference);
@ -17,13 +15,10 @@ public:
float get_angular() const; float get_angular() const;
void set_angular(const float val); void set_angular(const float val);
// Sets the linear and angular components to 0.
void set_zero(); void set_zero();
// Adds `accel`'s components, multiplied by `scalar`, to this one.
void add_scaled_accel(const Ref<GSAITargetAcceleration> &accel, const float scalar); void add_scaled_accel(const Ref<GSAITargetAcceleration> &accel, const float scalar);
// Returns the squared magnitude of the linear and angular components.
float get_magnitude_squared(); float get_magnitude_squared();
// Returns the magnitude of the linear and angular components.
float get_magnitude(); float get_magnitude();
GSAITargetAcceleration(); GSAITargetAcceleration();
@ -32,10 +27,7 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Linear acceleration
Vector3 linear; Vector3 linear;
// Angular acceleration
float angular; float angular;
}; };

View File

@ -8,14 +8,10 @@
#include "core/object/object.h" #include "core/object/object.h"
// Math and vector utility functions.
class GSAIUtils : public Object { class GSAIUtils : public Object {
GDCLASS(GSAIUtils, Object); GDCLASS(GSAIUtils, Object);
public: public:
// Returns the `vector` with its length capped to `limit`.
static _ALWAYS_INLINE_ Vector3 clampedv3(Vector3 vector, const float limit) { static _ALWAYS_INLINE_ Vector3 clampedv3(Vector3 vector, const float limit) {
float length_squared = vector.length_squared(); float length_squared = vector.length_squared();
float limit_squared = limit * limit; float limit_squared = limit * limit;
@ -27,36 +23,22 @@ public:
return vector; return vector;
} }
// Returns an angle in radians between the positive X axis and the `vector`.
// This assumes orientation for 3D agents that are upright and rotate
// around the Y axis.
static _ALWAYS_INLINE_ float vector3_to_angle(const Vector3 &vector) { static _ALWAYS_INLINE_ float vector3_to_angle(const Vector3 &vector) {
return atan2(vector.x, vector.z); return atan2(vector.x, vector.z);
} }
// Returns an angle in radians between the positive X axis and the `vector`.
static _ALWAYS_INLINE_ float vector2_to_angle(const Vector2 &vector) { static _ALWAYS_INLINE_ float vector2_to_angle(const Vector2 &vector) {
return atan2(vector.x, -vector.y); return atan2(vector.x, -vector.y);
} }
// Returns a directional vector from the given orientation angle.
// This assumes orientation for 2D agents or 3D agents that are upright and
// rotate around the Y axis.
static _ALWAYS_INLINE_ Vector2 angle_to_vector2(const float angle) { static _ALWAYS_INLINE_ Vector2 angle_to_vector2(const float angle) {
return Vector2(sin(-angle), cos(angle)); return Vector2(sin(-angle), cos(angle));
} }
// Returns a vector2 with `vector`'s x and y components.
static _ALWAYS_INLINE_ Vector2 to_vector2(const Vector3 &vector) { static _ALWAYS_INLINE_ Vector2 to_vector2(const Vector3 &vector) {
return Vector2(vector.x, vector.y); return Vector2(vector.x, vector.y);
} }
// Returns a vector3 with `vector`'s x and y components and 0 in z.
static _ALWAYS_INLINE_ Vector3 to_vector3(const Vector2 &vector) { static _ALWAYS_INLINE_ Vector3 to_vector3(const Vector2 &vector) {
return Vector3(vector.x, vector.y, 0); return Vector3(vector.x, vector.y, 0);
} }

View File

@ -17,15 +17,6 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Determines any agent that is in the specified list as being neighbors with the
// owner agent, regardless of distance.
// @category - Proximities
// Returns a number of neighbors based on a `callback` function.
//
// `_find_neighbors` calls `callback` for each agent in the `agents` array and
// adds one to the count if its `callback` returns true.
// @tags - virtual
}; };
#endif #endif

View File

@ -31,18 +31,8 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Base container type that stores data to find the neighbors of an agent.
// @category - Proximities
// @tags - abstract
// The owning agent whose neighbors are found in the group
Ref<GSAISteeringAgent> agent; Ref<GSAISteeringAgent> agent;
// The agents who are part of this group and could be potential neighbors
Vector<Ref<GSAISteeringAgent>> agents; Vector<Ref<GSAISteeringAgent>> agents;
// Returns a number of neighbors based on a `callback` function.
//
// `_find_neighbors` calls `callback` for each agent in the `agents` array and
// adds one to the count if its `callback` returns true.
// @tags - virtual
}; };
#endif #endif

View File

@ -23,17 +23,8 @@ public:
protected: protected:
static void _bind_methods(); static void _bind_methods();
// Determines any agent that is in the specified list as being neighbors with the owner agent if
// they lie within the specified radius.
// @category - Proximities
// The radius around the owning agent to find neighbors in
float radius; float radius;
int _last_frame; int _last_frame;
// Returns a number of neighbors based on a `callback` function.
//
// `_find_neighbors` calls `callback` for each agent in the `agents` array that lie within
// the radius around the owning agent and adds one to the count if its `callback` returns true.
// @tags - virtual
}; };
#endif #endif