2023-01-13 21:13:57 +01:00
|
|
|
|
2023-01-13 21:29:17 +01:00
|
|
|
#include "gsai_flee.h"
|
2023-01-13 21:13:57 +01:00
|
|
|
|
2023-01-13 21:35:07 +01:00
|
|
|
// Calculates acceleration to take an agent directly away from a target agent.;
|
|
|
|
// @category - Individual behaviors;
|
2023-01-13 21:13:57 +01:00
|
|
|
|
2023-01-13 21:35:07 +01:00
|
|
|
void GSAIFlee::_calculate_steering(const GSAITargetAcceleration &acceleration) {
|
|
|
|
acceleration.linear = ((agent.position - target.position).normalized() * agent.linear_acceleration_max);
|
|
|
|
acceleration.angular = 0;
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-13 21:35:07 +01:00
|
|
|
GSAIFlee::GSAIFlee() {
|
|
|
|
}
|
2023-01-13 21:13:57 +01:00
|
|
|
|
2023-01-13 21:35:07 +01:00
|
|
|
GSAIFlee::~GSAIFlee() {
|
|
|
|
}
|
2023-01-13 21:13:57 +01:00
|
|
|
|
2023-01-13 21:35:07 +01:00
|
|
|
static void GSAIFlee::_bind_methods() {
|
|
|
|
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIFlee::_calculate_steering);
|
|
|
|
}
|