flashlight adjustment, cant fall off map, ui sounds

This commit is contained in:
Persephone Bubblegum-Holiday 2025-08-17 18:45:20 -07:00
parent 2ec79e56fc
commit 0ae10c2451
10 changed files with 130 additions and 2 deletions

View file

@ -2,6 +2,8 @@ class_name Player extends CharacterBody3D
@export var current_map: String
var startPosition: Vector3
var SPEED_BASE: float = 2
var SPEED_CROUCHED: float = 1
var SPEED_RUNNING: float = 4
@ -40,6 +42,7 @@ func _ready() -> void:
capture_mouse()
if ($Camera.fov != GlobalVariables.FOV):
$Camera.fov = GlobalVariables.FOV
startPosition = self.position
func _unhandled_input(event: InputEvent) -> void:
if (interact):
@ -64,6 +67,25 @@ func _unhandled_input(event: InputEvent) -> void:
pass
elif event.is_action_pressed(&"freeroam_debug_menu"):
$DebugMenu.visible = !$DebugMenu.visible
elif event.is_action_pressed(&"freeroam_respawn"):
self.position = startPosition
elif event.is_action_pressed(&"freeroam_flashlight_zoom_in"):
if ($Camera/Flashlight.visible):
if ($Camera/Flashlight.spot_angle > 2):
$Camera/Flashlight.spot_angle -= 2
$FlashlightSFX.pitch_scale = $Camera/Flashlight.spot_angle/10.0
$FlashlightSFX.play()
elif event.is_action_pressed(&"freeroam_flashlight_zoom_out"):
if ($Camera/Flashlight.visible):
if ($Camera/Flashlight.spot_angle < 88):
$Camera/Flashlight.spot_angle += 2
$FlashlightSFX.pitch_scale = $Camera/Flashlight.spot_angle/10.0
$FlashlightSFX.play()
elif event.is_action_pressed(&"freeroam_flashlight_zoom_reset"):
if ($Camera/Flashlight.visible):
$Camera/Flashlight.spot_angle = 30
$FlashlightSFX.pitch_scale = $Camera/Flashlight.spot_angle/10.0
$FlashlightSFX.play()
elif event.is_action_pressed(&"freeroam_camera_zoom_in"):
if ($Camera.fov > 2):
$Camera.fov -= 2
@ -121,6 +143,9 @@ func _physics_process(delta: float) -> void:
if mouse_captured: _handle_joypad_camera_rotation(delta)
velocity = _walk(delta) + _gravity(delta) + _jump(delta)
move_and_slide()
if (self.position.y < -20):
jump_vel = Vector3(0, 50, 0)
$BoingSFX.play()
func capture_mouse() -> void:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)