Basically, I have set the Camera CFrame to a part in workspace and the part is rotating to the player
This is the script (Local Script):
local part = workspace.View
local Player = game.Players.LocalPlayer
while wait() do
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
game.Workspace.CurrentCamera.CFrame = part.CFrame
part.CFrame = CFrame.new(part.Position, Player.Character:WaitForChild("Head").Position);
end
Heartbeat fires AFTER the Physics completed meaning that it is more accurate than RenderStepped which would have a one frame delay from when the Player moves and when the Camera Positions its self.
Hmmm this is quite interesting, didn’t know about heartbeat.
Tried it out and it seems like there is a slight smoothness than renderstepped.
Thank you!
In this cae @OP wants to make the Camera track the Player.
The Character is affected by Physics meaning that it’s position might not be the same as before Physics had been Calculated.
You can see the effect of this when setting the Characters position using RenderStepped compared to Heartbeat (2 different examples both in startercharacterscripts).
game:GetService("RunService").RenderStepped:Connect(function()
script.Parent:PivotTo(CFrame.identity) -- choppy since the Character could move due to Physics until this is set again (RenderStepped is before Physics)
end)
game:GetService("RunService").Heartbeat:Connect(function()
script.Parent:PivotTo(CFrame.identity) -- not choppy since it's set after Physics have completed
end)
But the character model’s pivot isn’t being set every frame, the client’s camera’s pivot is. Looking at the script setting the camera’s ‘CameraSubject’ property and the humanoid’s ‘CameraOffset’ property would suffice and be more performant.
I was talking about Physics related changes and not changes of Position directly made by scripts. Altough setting the Camera Type isn’t something I tought of..