fix: player detector checks normalized dot product

This commit is contained in:
Sara Gerretsen 2026-01-30 21:29:46 +01:00
parent 0b656459dc
commit 55f254d4ec
2 changed files with 2 additions and 2 deletions

View file

@ -25,7 +25,7 @@ bool PlayerDetector::check() const {
Vector3 const position{ get_global_position() };
Vector3 const target{ PlayerBody::get_singleton()->get_global_position() + Vector3{ 0.f, 1.5f, 0.f } };
// check if the target is in a view cone
if (forward.dot(target - position) < this->min_sight_dot) {
if (forward.dot((target - position).normalized()) < this->min_sight_dot) {
return false;
}
// check if the target is in range

View file

@ -26,7 +26,7 @@ private:
float max_hearing_range{ 100.f };
float max_sight_range{ 60.f };
float min_sight_dot{ 0.7f };
float min_sight_dot{ 0.6f };
double query_time{ 0.3 };
double query_timer{ 0.0 };