Camera "Clicks" into place when tween completes

When the camera is set to scriptable mode, tweens “click” into place, which is very janky if the result should be smooth:

At the end of each tween, observe the sudden shift in the orientation of the camera.

Repo: Camera Clicks into position Repo File.rbxl (55.3 KB)

--!strict

if not game:IsLoaded() then
	game.Loaded:Wait()
end

while true do
	print("Camera scriptable = true")
	workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
	
	print("Tweening close")
	local CameraTween = game.TweenService:Create(
		workspace.CurrentCamera,
		TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut),
		{CFrame = CFrame.new(0, 5, 0, 0.05, -1, 0.15, 0, 0.15, 1, -1, -0.05, 0)
		}
	)
	CameraTween:Play()
	CameraTween.Completed:Wait()
	print("TweenEnded close")
	
	task.wait(1)
	
	print("Tweening far")
	local CameraTween = game.TweenService:Create(
		workspace.CurrentCamera,
		TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut),
		{CFrame = CFrame.new(0, 1663, 0, 0.05, -1, 0.15, 0, 0.15, 1, -1, -0.05, 0)
		}
	)
	CameraTween:Play()
	CameraTween.Completed:Wait()
	print("TweenEnded far")
	
	task.wait(1)
	
	print("Camera scriptable = false")
	workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
	
	task.wait(1)
end

Expected behavior

Camera smoothly interpolates into place, without “clicking”.

2 Likes

The Camera Position seems fine in the video and with the code excerpt, but while watching the Camera CFrame Property in the Properties Window, I noticed that the Rotation snaps slightly when the Tween finishes. Maybe this could be some imperfection in the Roblox Camera code itself or imprecision in the CFrame, who knows? I have a Teleport Script which does something very similar with Scripting the Camera and it doesn’t seem to suffer this issue with the Rotation, but it’s based on the Character Pivot so sometimes it does get a little snappy but not like this.

I’m unsure what’s causing the issue either, but I would expect full control over the camera if the camera type is set to scriptable.

It seems to be easy to reproduce, so it’s definitely some internal problem.

1 Like

You do get full control over the Camera when it is set to Scriptable, luckily, but it seems like it only does that when setting the Camera Type back to Custom. I do have a new theory as to why this might be happening though. The Camera when set to Custom always tries to point to the center of the Characters Head. Maybe your code does not take into account that which could be a plausible reason for the Rotation snapping. Your Position looks right, but the Camera might have to do some slight corrections in order to orbit back around the pivot exactly. You should try to make it use the Head Position as a reference point if you aren’t already and see if that resolves the snapping. Good luck.

1 Like

Just to clarify: when the tween finishes in the video, the camera type is still scriptable.

I understand the relative to head workaround, however, for things like cutscenes or other non-character-oriented camera animations, this isn’t possible to do.

Oh, I guess I misinterpreted what you showed a bit, oops. What if you tried using a CFrameValue Object to check whether TweenService itself is causing the issue by setting the Camera CFrame Property to the ValueObject Value when the Changed Signal fires? (I could show you a code excerpt of my idea if my description is too confusing over text as well) This wouldn’t be a solution to the problem, but rather a method of possibly diagnosing the source of it. I’m genuinely puzzled as to why this occurs as well. Like I’ve said it’s never happened to me whenever I try to Tween the Camera but in my case, I only change the Y-axis.

After some thought and testing, this happens when the provided CFrame is not orthonormal (meaning the three direction vectors are not mutually orthogonal). I’m guessing the camera tries to normalize itself whenever possible.

This seems like an intentional feature, although it mildly defeats the purpose of the scriptable state.

1 Like

I’m glad you figured it out. I never knew about these CFrame terms before, but, if you think it is intended behavior, you should mark that reply as the solution so people know it’s been solved. It’s odd that control over the Camera is hindered even when Scriptable, but maybe the Roblox Engineers are doing it for a similar reason Cylinders aren’t evenly round; it benefits most regular Developers without them knowing, but just in your case it went against you. Happy Studio’ing.

1 Like

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