Tween into first person?

Simple question, How can I tween the camera into first person view? Needs to work while they are walking.

1 Like

In my opinion, using tweens in this scenario won’t work. You can use the CFrame:Lerp() function instead, since if you repeatedly create new tweens to account the new dynamic position of the head every few seconds it’s going to look weird.

Also this should be in #help-and-feedback:scripting-support.

1 Like

Sorry, mis clicked.

I’ll give lerping a try.

You can pair it with a for loop for the alpha parameter in the function to adjust the “smoothness” of the lerp.

for i = 0,1,1/25do
   if player.Character and player.Character:FindFirstChild("Head") then
		camera.CFrame = camera.CFrame:Lerp(player.Character:FindFirstChild("Head").CFrame,i)
		game:GetService("RunService").RenderStepped:Wait()
	end		
end

It goes to the head in a smooth motion but the character spins during this. Can I fix this?

1 Like

Can you show a video of that happening?

Change the camera type to scriptable.

1 Like

Don’t forget to change it back to Custom when you are done lerping.

Also never thought of that idea.

1 Like

Ye, I tried this and it works fine but when I lerp to the head and then lock into first person, the camera jumps back a bit, Should I be lerping to the head?

What do you mean by “jumps back a bit”?


Notice how when it goes to the character there is a little delay before my body disappears

Isn’t that what you’re supposed to do…?

Well, I figured since it went back a bit the first person camera cframe isn’t the same as the head cframe.

You should be lerping to the character’s head.

I would recommend keeping the camera in custom then lerping the zoom instead of the CFrame because I think it’s simpler and it doesn’t lock the camera rotation too.

Here are two methods to do that:

  • Set CameraMaxZoomDistance and CameraMinZoomDistance to 0.5 and use the default interpolation (The default is spring based. It is pretty fast though, if you want it slower use the second option.)

  • Get the current zoom using the camera’s CFrame.Position and Focus.Position. Then set CameraMaxZoomDistance and CameraMinZoomDistance to the current zoom and tween/lerp both CameraMaxZoomDistance and CameraMinZoomDistance until they are 0.5

(Player.CameraMinZoomDistance)
(Player.CameraMaxZoomDistance)

1 Like

This is pretty obscure, but actually the first person camera position is head.Position - camera.CFrame.LookVector * 0.5.

1 Like

Not sure how to Lerp a number so I just tweened it. Worked fine.

1 Like

If you’re curious the lerp function for numbers is this:

local function (a, b, percent)
    return a + (b - a) * percent
end

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