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