Better controller camera movement

Godot Version

godot 4

Question

I’m working on an fps stealth horror thing, trying to get controller support working, and it’s going great (input actions area a godsend). but my camera movement just doesnt feel right for whatever reason. it’s kinda stiff i guess is how I would describe it. does anyone have any tips for making better controller camera movement?

heres the code:

func _controllerCam():
	var x =  Input.get_axis("Left","Right")
	var y = Input.get_axis("Up","Down")
	head.rotate_y(-x * CONTROLLER_SENSITIVITY *.05)
	camera.rotate_x(-y * CONTROLLER_SENSITIVITY * .05)
	camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-89), deg_to_rad(90))

As a quick suggestion, try using lerp when moving or rotating your camera, it will make it alot smoother. So rather than setting it directly, lerp towards it. This will interpolate the current value and the target rotation or position values for you.

Lerp (and lerp_angle and lerpf etc)

Hope that helps.

PS Camera damping also makes your game feel smoother and less stiff. It means making the camera move a bit more naturally, not just copying the player’s every move. Think of it like a gentle, lazy follow. For example: Zooming out a little when your character runs, then zooming back in when they slow down. It sounds small, but it can make your game feel way more awesome. Getting the camera just right can take a long time, but it’s totally worth it!

1 Like

I came up with the following, which is marginally better, but it’s not quite where I want it to be. have any other resources that might help?

func _controllerCam():
	var x =  Input.get_axis("Left","Right")
	var y = Input.get_axis("Up","Down")
	head.rotation.y = lerpf(head.rotation.y, head.rotation.y + -x * CONTROLLER_SENSITIVITY *.05, .1)
	camera.rotation.x = lerpf(camera.rotation.x, camera.rotation.x + -y * CONTROLLER_SENSITIVITY * .05, .1)
	camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-89), deg_to_rad(90))

modified this from a tutorial, works pretty well

func _controllerCam(delta):
	var x =  Input.get_axis("Left","Right")
	var y = Input.get_axis("Up","Down")
	rotation_velocity = rotation_velocity.lerp(Vector2(x,y) * -CONTROLLER_SENSITIVITY * 10, delta * (Controller_Smoothing/100))
	rotation_velocity = rotation_velocity.lerp(Vector2.ZERO, (Controller_resistance/100))
	head.rotate_y(deg_to_rad(rotation_velocity.x))
	camera.rotate_x(deg_to_rad(rotation_velocity.y))
	camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-89), deg_to_rad(90))
1 Like