I am using orientation to turn a bus and a camera is supposed to follow the bus. I am using tween to smoothly interpolate the camera to the Bus position but orientation goes from -180 to 180 and when I rotate in a full circle or rotate paste -180*, the camera spins 360 degrees.
Here is a video:
Here is code:
local Info = TweenInfo.new(0.2)
local goal = {}
goal.Orientation = Bus.Orientation
TweenService:Create(Bus.CamPart,Info,goal):Play()
I think tweeting orientation instead of CFrame is what’s causing this. With orientation, -360 (or something similar) is trying to tween back to 0, even though -360 is the same rotation as 0. Using CFrame you can avoid these cases since it relies on basis vectors instead of a rotation angle (you can still construct CFrames from angles but -360 and 0 would give the same CFrame, it’s a unique orientation like you said)
There are some good tutorials about CFrames here on the forum, try looking at some and see if you like any of them. Also the DevHub page for CFrame has some good info there you can check out. If you do orientation stuff a lot, it is good to get used to CFrames and even if you don’t fully understand them right away, over time they will become more familiar.
Instead of tweening the orientation (which is suffering from gimble lock as shown in the video), you can use a CFrame and tween its rotational matrix. e.g.