Camera breaks after interpolation

After interpolation, it is not possible to set the camera back to default behaviour where it focuses on the player character. While I’m aware it’s possible to use TweenService for this, Interpolate is a function created literally for this purpose, therefore it should work in one of the most common use cases.

To reproduce, try this in a blank baseplate:
First set the camera subject and camera type:

game.Workspace.CurrentCamera.CameraSubject = game.Workspace.Baseplate
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

Now run this code:

local camera = game.Workspace.CurrentCamera
local plr = game.Players:FindFirstChildOfClass("Player")

camera:Interpolate(plr.Character.Head.CFrame, plr.Character.Head.CFrame, 0.6)
camera.InterpolationFinished:Connect(function()
	print("Putting camera back.")
	camera.CameraSubject = plr.Character.Humanoid
	camera.CameraType = Enum.CameraType.Follow
end)

I made a scripting support thread about this earlier:

1 Like

You’re interpolating to two of the same values. By making the second argument different from the first, this worked fine for me.

Try something like this:

camera:Interpolate(plr.Character.Head.CFrame, plr.Character.Head.CFrame + Vector3.new(0, 1, 0), 0.6)
1 Like

It’s definitely time to port this over to TweenService. Camera:Interpolate is now very much outdated and has been approved for deprecation. Unlike some API calls which live for years after deprecation, this one will not be able to since its setting of Focus and camera orientation from C++ conflicts with our goals of having camera control managed entirely in Lua where developers have total control over it.

Camera:Interpolate only ever did simple linear interpolation of camera and focus position, without easing, and with undesirable behavior near the +/-Y poles because of the lookAt function’s singularities. TweenService can do simple linear tweens too, but it offers a wide variety of easing functions that make things look better in most real use cases, and it uses slerp when interpolating CFrames, so much more sensible rotation behavior overall.

9 Likes

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