From 6456d8179483334513620467c79b9fb6462dbb95 Mon Sep 17 00:00:00 2001 From: Sara Date: Sat, 30 Aug 2025 13:14:23 +0200 Subject: [PATCH] feat: added delay to detecting the player --- modules/wave_survival/player_detector.cpp | 3 ++- modules/wave_survival/player_detector.h | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/wave_survival/player_detector.cpp b/modules/wave_survival/player_detector.cpp index 5e005e2f..e87adba6 100644 --- a/modules/wave_survival/player_detector.cpp +++ b/modules/wave_survival/player_detector.cpp @@ -46,7 +46,8 @@ void PlayerDetector::process(double delta) { } else { this->query_timer = this->query_time; bool const new_awareness{ check() }; - if (new_awareness != this->aware_of_player) { + this->awareness = CLAMP(this->awareness + (new_awareness ? this->awareness_increments : -this->awareness_increments), 0.0, 1.0); + if (this->awareness >= 1.0) { set_aware_of_player(new_awareness); } } diff --git a/modules/wave_survival/player_detector.h b/modules/wave_survival/player_detector.h index 1230d0e9..83725821 100644 --- a/modules/wave_survival/player_detector.h +++ b/modules/wave_survival/player_detector.h @@ -23,13 +23,15 @@ public: private: bool aware_of_player{ false }; - float max_hearing_range{ 40.f }; + float max_hearing_range{ 100.f }; - float max_sight_range{ 20.f }; + float max_sight_range{ 60.f }; float min_sight_dot{ 0.7f }; double query_time{ 0.3 }; double query_timer{ 0.0 }; + double awareness{ 0.0 }; + double awareness_increments{ 0.4 }; PhysicsDirectSpaceState3D::RayParameters ray_params{};