Make the camera smoothly tween to the player


slap battles has an option in settings for a “death camera”. when the player dies, the camera stays still and lerps direction towards the player. Then it moves back to where it should be when it respawns. I also realized that it does it smoothly even while the character is moving mid-tween. how does this happen? how could i do it myself? I already got the camera to face the character when died but how can i get it to move back to where it should be?

1 Like

So, I only know how to do the beginning part. Use CFrame:lookAt() in a loop so that the camera looks at the player. Here is an example that was rushed.

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
local TweenService = game:GetService("TweenService")

while wait() do
	TweenService:Create(workspace.CurrentCamera, TweenInfo.new(0.2, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out), {CFrame = CFrame.lookAt(workspace.CurrentCamera.CFrame.Position, game.Players.LocalPlayer.Character.HumanoidRootPart.Position)}):Play()
end

I found the solution myself. You can use :Lerp() to get a part as close as the alpha is to 1. (ex: lerp(destination, 0.5) would get me halfway there. This is really only useful for setting the camera focus or custom camera systems since they like to mess with the camera system but hey it is what it is :man_shrugging:

If you don’t know the basics, please don’t try to help.
You are leading people into a pitfall literally.
Edit: oh wait its a 1 year old post…

You can just use TweenService.
Why would you use lerp if you are not making custom tweening or some math operations?

Well I’m kinda new to scripting. Sorry about that.

Nah its ok
MB for not checking the date of the post

use tweenservice for tweening the alpha.

that slow.
Get raw math formula for it instead.