Issue Tweening CFrame Angles

I’m trying to tween the camera position and orientation. The position tweens nicely but the orientation doesn’t! How do I fix this issue? I’ve been strugling with this for a couple of weeks now.

There aren’t any other scripts tweening the camera as this happens.

Here is a snippet of my code:

		local camera = game:GetService("Workspace").CurrentCamera

		local cameraResetTween = TweenService:Create(camera, cameraInfo, {CFrame = CFrame.new(20, 35, 20) * CFrame.Angles(math.rad(90), math.rad(45), 0)})
		cameraResetTween:Play()

I’ve attached a screenshot of the properties of the camera after the tween completed.

Screenshot 2025-02-17 at 1.02.25 PM

Feel free to ask questions
Thanks.

The first thing that sticks out to me is that you’ve used CFrame.Angles to set the target rotation, which uses an XYZ rotation order. That means the tween will rotate the camera around the x-axis first, then y, then z. I’m not entirely sure what it means when you say that the orientation doesn’t tween “nicely”, but that’s where I’d check first. Try using the fromOrientation or fromEulerAnglesYXZ constructors to see if it makes the camera rotate the way you want it to.

I’d also try using the lookAt constructor as well. You’d be able to construct the cframe without needing to do any of the math and it might have some behind-the-scenes code magic that makes it all work somehow.

1 Like

Thanks!

using fromOrientation (same as fromEulerAnglesYXZ) has worked perfectly and is just what I intented for!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.