Hello DevForum,
I am making a game where the camera always follows the player from one specific angle. I’ve implemented the following script in StarterPlayerScripts to achieve this:
local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
game:GetService("RunService").RenderStepped:Connect(function()
local c = game.Players.LocalPlayer.Character
if not c then return end
local h = game.Players.LocalPlayer.Character:FindFirstChild("Head")
local hrp = game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
if not h then return end
local pos = hrp.Position + Vector3.new(0,5,-15) -- Aribitrary, can tweak if necessary.
local lookAt = h.Position
cam.CFrame = CFrame.new(pos,lookAt)
end)
This works as expected, but delivers a very unstable ‘wobbly’ camera position. This is because I am setting the camera relative to the HumanoidRootPart, which always moves by a tiny amount on the Y axis.
GIF URL: https://gyazo.com/ebd7832287424b369eefd409f028da5e
Is there anything I could do to fix this? I’ve tried rounding the Y property of the HumanoidRootPart down before processing, this leads to visible cuts when you ascend/descend.