I've been looking around for a good couple of hours now, and I've been unable to find help for what I'm trying to do. Basically, I'm trying to make the camera angle tilt when the player strafes left and right. My problem is both I can't find someone else who has explained this online, and I can't find official documentation that mentions changing the camera roll. My current skills with Gdscript have me at a dead end here, I would appreciate help!

Camera inherits from Spatial, so has a Transform property and can be arbitrarily rotated on any axis, there is nothing special about camera roll. So you should just be able to use the "rotate_z" function. https://docs.godotengine.org/en/stable/classes/class_spatial.html#class-spatial-method-rotate-z

your_camera_node.rotate_z(deg2rad(30))

mmmm you could modify the position of the camera depending on whether or not it is moving if he is a player or whatever is in motion, you could make a variable that saves the state and then in the process check the status

example:

var is_move = false

onready var cam = $camera

var default_camera_pos   # to store the original camera position


func _ready():
	default_camera_pos = cam.position


func _process(delta):
	if is_move:
		cam.position.x = cam.position.x + 10
	else:
		cam.position.x = default_camera_pos.x

# assuming that the logic to move is the physics_process

func _physics_process(delta):
	# you logic to move
	is_move = true # or false depending you logic

this is the example i can think of that might work, i haven't tried it Also here I only handle the x position so that it moves a little to the right

for rotation find rotation degress It would be more or less the same, but this time you only have to change the x or z axis instead of the position

@cybereality said: Camera inherits from Spatial, so has a Transform property and can be arbitrarily rotated on any axis, there is nothing special about camera roll. So you should just be able to use the "rotate_z" function. https://docs.godotengine.org/en/stable/classes/class_spatial.html#class-spatial-method-rotate-z

your_camera_node.rotate_z(deg2rad(30))

Ahhh, I understand now. One more quick question: if I wanted to limit how much the camera tilts, I would use clamp, right? And if so, what float would I need to put for the first value?

See the docs for clamp here: https://docs.godotengine.org/en/stable/classes/class_@gdscript.html#class-gdscript-method-clamp

If you want to use degrees, you would but the adjusted value first, then the limits. So to limit to between +-15 degrees you can do this:

var camera_tilt = #do whatever you need to adjust tilt here
camera_tilt = clamp(camera_tilt, -15, 15)
your_camera_node.rotate_z(deg2rad(camera_tilt))

Thanks for the assistance, I appreciate it, but I'm feeling kinda dumb for not getting this. When I tried rotate_z, even with a clamp the angle would continue to rotate. Actually what I have now, the limiter is the camera_tilt variable. Below I have it set to be 10 degrees in either direction, but the clamp should only have it be 5 degrees if I'm understanding that correctly . But regardless, it rotates 10 degrees in either direction. I was also unable to figure out a way to have them only rotate that many degees once when pressing a single key, though that might have had to do with me having the rotate_z code in an is_action_pressed command, so I've kinda jank'd together a way to get the results, albeit without being able to make the rotation smooth. This is what I got:

var camera_tilt = 10

func _physics_process(delta):
camera_tilt = clamp(camera_tilt, -5, 5)

if Input.is_action_just_pressed("move_left"):
	cam.rotate_z(deg2rad(camera_tilt))
if Input.is_action_just_pressed("move_right"):
	cam.rotate_z(deg2rad(-camera_tilt))

if Input.is_action_just_released("move_left"):
	cam.rotate_z(deg2rad(-camera_tilt))
if Input.is_action_just_released("move_right"):
	cam.rotate_z(deg2rad(camera_tilt))

Oh, I'm sorry. You want to clamp the actually rotation, not the camera_tilt variable. So you can take out the clamp from the first line, then add this at the end of the function:

cam.rotation.z = clamp(cam.rotation.z , -5, 5)

That did the trick! Thank you! Here's the updated code for anyone else who comes across this:

var camera_tilt = 1  #The speed which the camera will rotate

func _physics_process(delta):
	if Input.is_action_pressed("move_left"):
		cam.rotate_z(deg2rad(camera_tilt))
	if Input.is_action_pressed("move_right"):
		cam.rotate_z(deg2rad(-camera_tilt))
	
#Returning the camera angle back to zero. The 0.5 has the camera rotate back at a slower rate.
	if not Input.is_action_pressed("move_left"):
		if cam.rotation.z > 0:
			cam.rotate_z(deg2rad(-camera_tilt * 0.5))
	if not Input.is_action_pressed("move_right"):
		if cam.rotation.z < 0:
			cam.rotate_z(deg2rad(camera_tilt * 0.5))
		
	cam.rotation.z = clamp(cam.rotation.z , -0.05, 0.05)  #Changing the thresholds will change how far the camera will rotate in either direction
a year later