extends CharacterBody3D const WALK_SPEED = 3.0 const MOUSE_SENS = 0.002 var has_flashlight = false var has_key = false @onready var flashlight = $"../FlashLight" var mouse_mode = 2 func _ready(): Input.set_mouse_mode(mouse_mode) func _input(event): if event is InputEventMouseMotion and mouse_mode == 2: $Pivot.rotate_y(-event.relative.x*MOUSE_SENS) $Pivot/Camera.rotate_x(-event.relative.y*MOUSE_SENS) elif event.is_action_pressed("mode"): mouse_mode = mouse_mode ^ 1 Input.set_mouse_mode(mouse_mode) elif event.is_action_pressed("alt") and has_flashlight: $Pivot/Camera/FlashLight/SpotLight3D.visible = !$Pivot/Camera/FlashLight/SpotLight3D.visible func _physics_process(delta): if mouse_mode == 2: var input_dir = Input.get_vector("move_left", "move_right", "move_forward", "move_back") var direction = ($Pivot.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() velocity.x = direction.x * WALK_SPEED velocity.z = direction.z * WALK_SPEED move_and_slide() func _on_flash_light_input_event(camera, event, position, normal, shape_idx): if event is InputEventMouseButton and event.is_action_pressed("interact"): $Pivot/Camera/FlashLight.visible = true has_flashlight = true if flashlight: flashlight.visible = false