Lerping the rotation gives weird results?

Hello, new to godot and I’m trying to make the camera lerp smoother but it’s giving me unintended results

This is what it looks like without me lerping it at all and directly setting it

cam.rotation = Vector3(deg_to_rad(rotation[0]), deg_to_rad(rotation[1]), deg_to_rad(rotation[2]))

What it looks like when I try to lerp

cam.rotation = cam.rotation.lerp(Vector3(deg_to_rad(rotation[0]), deg_to_rad(rotation[1]), deg_to_rad(rotation[2])), delta * self.SPEED)

Try using a Quaternion

Alright could you help me set that up the rotation in Godot is weird, also could you maybe expain why it’s doing that in the first place?

Like it works on the docs

Lerp isn’t as useful for angles, that isn’t for angles but for a position in the example

You could try slerp instead, but better to use a quaternion, check the documentation, you’d probably use Euler angle constrictor for it

Finally, figured it out and it was easier and I should’ve known this would work so basically you have like construct a new rotation and then use lerp_angle for each axis and it works PERFECTLY! No need for Quaternions whatever the hell those are

var targetRotation = Vector3(deg_to_rad(rotation[0]), deg_to_rad(rotation[1]), deg_to_rad(rotation[2]))
var lerpedRotation = Vector3(
   lerp_angle(cam.rotation.x, targetRotation.x, delta * SPEED),
   lerp_angle(cam.rotation.y, targetRotation.y, delta * SPEED),
   lerp_angle(cam.rotation.z, targetRotation.z, delta * SPEED)
cam.rotation = lerpedRotation


1 Like