Godot Version
4.2
Question
I’d like to add a flashlight that moves, and the camera follows it. I found a tutorial to do just this, but i’ve already got a character controller made that i really like,
i’m pretty new to this, and i can’t wrap my head around how to add this to my code without ruining everything. Any help would be very much appreciated.
my mouse movement code:
@onready var head = $Head
@onready var camera = $Head/Camera3D
@onready var hand = $Hand
@onready var flashlight = $Hand/SpotLight3D
func _unhandled_input(event):
if event is InputEventMouseMotion:
head.rotate_y(-event.relative.x * SENSITIVITY)
camera.rotate_x(-event.relative.y * SENSITIVITY)
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-80), deg_to_rad(80))
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)