17 double relax_distance,
float evade_wt) {
20 _evade_target = target_object;
21 _evade_distance = panic_distance;
22 _evade_relax_distance = relax_distance;
23 _evade_weight = evade_wt;
26 _evade_activate_done =
false;
39 assert(_evade_target &&
"evade target not assigned");
41 _evade_direction = _ai_char->_ai_char_np.
get_pos(_ai_char->_window_render) - _evade_target.
get_pos(_ai_char->_window_render);
42 double distance = _evade_direction.length();
44 _evade_direction.normalize();
45 LVecBase3 desired_force = _evade_direction * _ai_char->_movt_force;
47 if(distance > (_evade_distance + _evade_relax_distance)) {
48 if((_ai_char->_steering->_behaviors_flags | _ai_char->_steering->_evade) == _ai_char->_steering->_evade) {
49 _ai_char->_steering->_steering_force = LVecBase3(0.0, 0.0, 0.0);
51 _ai_char->_steering->
turn_off(
"evade");
52 _ai_char->_steering->
turn_on(
"evade_activate");
54 return(LVecBase3(0.0, 0.0, 0.0));
58 return(desired_force);
68 _evade_direction = (_ai_char->_ai_char_np.
get_pos(_ai_char->_window_render) - _evade_target.
get_pos(_ai_char->_window_render));
69 double distance = _evade_direction.length();
70 _evade_activate_done =
false;
72 if(distance < _evade_distance) {
73 _ai_char->_steering->
turn_off(
"evade_activate");
74 _ai_char->_steering->
turn_on(
"evade");
75 _evade_activate_done =
true;
void turn_on(std::string ai_type)
This function turns on any aiBehavior which is passed as a string.
LVecBase3 do_evade()
This function performs the evade and returns an evade force which is used in the calculate_prioritize...
void turn_off(std::string ai_type)
This function turns off any aiBehavior which is passed as a string.
LPoint3 get_pos() const
Retrieves the translation component of the transform.
void evade_activate()
This function checks for whether the target is within the panic distance.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...