Godot Version
4.5
Question
I’ve just moves from 2d to 3d and I’m having a lot of trouble adapting to 3d space (mainly how to use transform)
I want to have a go at making a third person camera with a soulslike lock on system but I can’t figure out how to properly rotate the camera arm
My camera consists of 2 nodes a SpringArm3D and a child Camera3D node
I have a script that locks on to a debug enemy. and currently my camera looks at the enemy although my camera mount (spring arm) stays in the place.
I cant really use look_at() since that will rotate the entier camera arm. I only want to move the camera arm around its yaw(?). x rotation
please ask for more info if needed not really sure which code to post since
func camera_ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
camera_arm.add_excluded_object(self)
func cam_process() -> void:
camera_arm.global_position = global_position # top level is true
if focus_point != null:
locked_camera()
func free_camera_input(event : InputEvent) -> void:
if event is InputEventMouseMotion:
#rotate camera arm around player
camera_arm.rotation.y -= event.relative.x * mouse_sensibility
camera_arm.rotation.x -= event.relative.y * mouse_sensibility
# force camera arm rotation not to exceed threshhold
camera_arm.rotation.x = clamp(camera_arm.rotation.x, -PI/3, PI/4)
camera_arm.rotation.y = wrapf(camera_arm.rotation.y,0.0, TAU)
func locked_camera() -> void:
cam.look_at(focus_point)
# then some logic here that makes the camera_arm be rotated to look at focus point
func update_cam_target_pos() -> void:
focus_point = current_target.global_position