SpringArm3D Jittering & Sudden Zoom

SpringArm3D Jittering & Sudden Zoom

Godot Version

4.6.3 stable

Question

I am currently experiencing very sudden zoom in the SpringArm and I haven’t found a way to smoothen out the difference in zoom when player is far away vs when player is standing close to a wall behind a building that necessitates the spring arm to zoom in so that there is nothing blocking the line of sight. I tried changing the settings in the Inspector below, for example changing the shape to SeparationRayShape3D, cylinder, whatever, and tried changing the spring length and margins but none of that worked.

From here you can see the camera is perfectly fine

but the moment I slightly zoom over to the left such that the line of sight to the player is obstructed and SpringArm activates, there is a very sudden jump between these two pictures. I tried adding code to interpolate it, but I found out it didn’t matter anyway because the internal logic of SpringArm always overwrites my camera.position.z settings.

func _process(delta):
	# Set position and rotation to targets
	position = position.lerp(camera_position, delta * 8)
	rotation_degrees = rotation_degrees.lerp(camera_rotation, delta * 6)
	# Let spring_length track desired zoom
	spring_arm.spring_length = lerp(spring_arm.spring_length, zoom, delta * 5)
	
	# Smooth when large jump in distance to player
	var target_dist = spring_arm.get_hit_length()
	var pull_speed = 15.0 if target_dist < camera.position.z else 6.0
	camera.position.z = lerp(camera.position.z, target_dist, delta * pull_speed)
	handle_input(delta)

Also when the SpringArm grazes the uneven surfaces of the buildings it causes jittering is there a way to fix this?

To interpolate you’d have to move your camera to a separate node and slowly copy the transform from a node/marker under the spring arm