Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified security camera to use player light level for detection #306

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions COGITO/CogitoObjects/cogito_security_camera.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ signal object_no_longer_detected
signal turned_off

@onready var audio_stream_player_3d: AudioStreamPlayer3D = $AudioStreamPlayer3D
@onready var lightmeter:CogitoAttribute = (CogitoSceneManager._current_player_node.player_attributes.get("lightmeter"))
@onready var player_light_level: float = lightmeter.value_current

@export var detection_ray_cast_3d: RayCast3D
@export var indicator_light: OmniLight3D

@export var detection_area : Area3D
@export var start_state : DetectorState
@export var only_detect_player : bool = true
@export var spot_time : float = 4.0
##Threshold at which Player is detected
@export var detection_threshold : float = 4.0
##Determines impact player light level has on detection
@export var light_level_detection_multipler : float = 0.05
@export var alarm_sound : AudioStream

@export_group("Detection indicator settings")
Expand Down Expand Up @@ -79,9 +84,11 @@ func detecting(delta: float):
if detected_objects.size() <= 0:
print("SecurityCamera DETECTING: No visible targets in detection area. Stopping detection.")
stop_detecting()

detection_time += delta
if detection_time >= spot_time:

player_light_level = lightmeter.value_current
detection_time += delta * (player_light_level*light_level_detection_multipler)

if detection_time >= detection_threshold:
# === THIS IS WHERE THE FULL DETECTION HAPPENS ===
print("SecurityCamera: Detected!")
current_state = DetectorState.DETECTED
Expand Down