Snapping back when aiming

Godot Version

4.3

Question

` I am running into an issue where when my player “aims” using the right mouse button the player will ‘snap back’ to the original orientation even though the camera rotation updates correctly.

So if I turn my player 45 degrees to the left, the camera will follow behind like it should and the player will also turn correctly. However, once the right mouse button is released, the camera stays correctly oriented but the player will snap back 45 degrees to the right.

Any advice would be helpful. Below is the aim function but I can add the full code if needed.

if Input.is_action_pressed("aim"):
			player_mesh.rotation.y = lerp_angle(player_mesh.rotation.y, camroot_h.rotation.y, delta * angular_acceleration)
		else:
			player_mesh.rotation.y = lerp_angle(player_mesh.rotation.y, atan2(direction.x, direction.z) - rotation.y, delta * angular_acceleration)

Is your player stationary when this happens?

Assuming direction is the current direction the player is moving and is calculated as the difference between their current and previous positions, then when the player is stationery then it would snap back to the default zero vector instead maybe