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.
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.