#Rotating the camera angle 90 degrees and having the player in sight.
1 messages · Page 1 of 1 (latest)
Here is the node with it's children provided
And here is the code below
@onready var cam: Camera3D = $Camera3D
# --- Player Follow ---
@export var target_path: NodePath
@export var move_speed := 5.0
@onready var target = get_node(target_path)
# --- Rotation ---
@export var rotate_speed := 5.0
var current_yaw = 90
var target_yaw = current_yaw
# --- Camera Offset ---
@export var camera_offset := Vector3(0, 10, -10)
func _process(delta):
if not target:
return
# Smoothly move rig toward player's X/Z, keep Y fixed
var target_pos = target.global_position
target_pos.y = global_position.y
global_position = global_position.lerp(target_pos, move_speed * delta)
# Rotate to Left/Right
if Input.is_action_just_pressed("ROTATE_LEFT"):
target_yaw -= 90
if Input.is_action_just_pressed("ROTATE_RIGHT"):
target_yaw += 90
# Normalize target_yaw
target_yaw = fmod(target_yaw, 360)
# Smoothly rotate rig
current_yaw = lerp_angle(current_yaw, target_yaw, rotate_speed * delta)
rotation_degrees.y = current_yaw
# Smoothly apply camera offset and look at player
cam.position = cam.position.lerp(camera_offset, move_speed * delta)
cam.look_at(global_position, Vector3.UP)```
Can vc and stream if necessary.