AIBehaviors¶
-
class
AIBehaviors
¶ This class implements all the steering behaviors of the AI framework, such as seek, flee, pursue, evade, wander and flock. Each steering behavior has a weight which is used when more than one type of steering behavior is acting on the same ai character. The weight decides the contribution of each type of steering behavior. The
AICharacter
class has a handle to an object of this class and this allows to invoke the steering behaviors via theAICharacter
. This class also provides functionality such as pausing, resuming and removing the AI behaviors of an AI character at anytime.Inheritance diagram
-
AIBehaviors
(AIBehaviors const&) = default¶
-
void
add_dynamic_obstacle
(NodePath obstacle)¶ This function starts the pathfinding obstacle navigation for the passed in obstacle.
-
void
add_static_obstacle
(NodePath obstacle)¶ This function allows the user to dynamically add obstacles to the game environment. The function will update the nodes within the bounding volume of the obstacle as non-traversable. Hence will not be considered by the pathfinding algorithm.
-
void
arrival
(double distance = 10.0)¶ This function activates arrival. This is the function we want the user to call for arrival to be done.
-
std::string
behavior_status
(std::string ai_type)¶ This function returns the status of an AI Type whether it is active, paused or disabled. It returns -1 if an invalid string is passed.
-
void
evade
(NodePath target_object, double panic_distance = 10.0, double relax_distance = 10.0, float evade_wt = 1.0)¶ This function activates evade_activate.
-
void
flee
(NodePath target_object, double panic_distance = 10.0, double relax_distance = 10.0, float flee_wt = 1.0)¶
-
void
flee
(LVecBase3 pos, double panic_distance = 10.0, double relax_distance = 10.0, float flee_wt = 1.0)¶ This function activates flee_activate and creates an object of the Flee class. This function is overloaded to accept a
NodePath
or anLVecBase3
.
-
void
flock
(float flock_wt)¶ This function activates flock. This is the function we want the user to call for flock to be done.
-
void
init_path_find
(char const *navmesh_filename)¶ should have different function names.
This function activates path finding in the character. This function accepts the meshdata in .csv format.
-
void
obstacle_avoidance
(float feeler_length = 1.0)¶ This function activates obstacle avoidance for a given character. This is the function we want the user to call for obstacle avoidance to be performed.
-
void
path_find_to
(NodePath target, std::string type = "normal")¶ This function checks for the source and target in the navigation mesh for its availability and then finds the best path via the A* algorithm Then it calls the path follower to make the object follow the path.
-
void
path_follow
(float follow_wt)¶ This function activates path following. This is the function we want the user to call for path following.
-
void
pause_ai
(std::string ai_type)¶ This function pauses individual or all the AIs.
-
void
pursue
(NodePath target_object, float pursue_wt = 1.0)¶ This function activates pursue. This is the function we want the user to call for pursue to be done.
-
void
remove_ai
(std::string ai_type)¶ This function removes individual or all the AIs.
-
void
resume_ai
(std::string ai_type)¶ This function resumes individual or all the AIs
-
void
seek
(LVecBase3 pos, float seek_wt = 1.0)¶ This function activates seek and makes an object of the Seek class. This is the function we want the user to call for seek to be done. This function is overloaded to accept a
NodePath
or anLVecBase3
.
-
void
start_follow
(std::string type = "normal")¶
-
void
wander
(double wander_radius = 5.0, int flag = 0, double aoe = 0.0, float wander_weight = 1.0)¶ This function activates wander. This is the function we want the user to call for flock to be done.
-