Hi, so I’m making a simple camera system similar to that of Five Nights at Freddy’s 4, where you can look behind yourself towards the bed, then back to the default view of the room, from right-to-left.
The issue I’m having is that sometimes when I use TweenService, it’ll actually rotate left-to-right since I think it determines that distance is shorter than if it were to rotate right-to-left. (I want the camera to always rotate clockwise first, then counter-clockwise as you look back to the room, so it’s like a look over your right shoulder.)
I remember having this problem before, but I wasn’t sure what the workaround was for this.
but how could that work for my case though? I’d think the same problem would occur, like even if I tweened the camera’s CFrame to that, it’d make sense for it to still rotate the wrong way as it sees that rotating counter-clockwise is the shorter distance rather than rotating clockwise.
Since my movements were as you say “fixed” I think it will still work,
and as @7z99 said I don’t know how you’re doing your angles but you can set angles to over 360 meaning it can go to 380 instead of using a hacky solution of 20
I’m actually really stumped on this, it shouldn’t be this difficult but it’s confusing me because it keeps rotating the other way, despite how I go about actually updating the target angle.
local targLeft = 180 -- left target
local targRight = -180 -- right target
local runService = game:GetService('RunService')
local camera = workspace.CurrentCamera
local left, right
function left()
camera.CFrame *= CFrame.Angles(0,math.rad(0.05),0)
local x,y,z = camera.CFrame:ToEulerAnglesXYZ()
if math.floor(math.deg(y)) == targLeft then
runService:UnbindFromRenderStep('left')
runService:BindToRenderStep('right', Enum.RenderPriority.Camera + 1, right)
end
end
function right()
camera.CFrame *= CFrame.Angles(0,math.rad(-0.05),0) -- ensure you do negative on the y axis, or positive on this and negative on the above
local x,y,z = camera.CFrame:ToEulerAnglesXYZ()
if math.floor(math.deg(y)) == targRight then
runService:UnbindFromRenderStep('right')
runService:BindToRenderStep('left', Enum.RenderPriority.Camera + 1, left)
end
end
runService:BindToRenderStep('left', Enum.RenderPriority.Camera + 1, left)