Hey, I’ve got a script that makes your character’s head and torso follow wherever the camera is looking. However, I also want to apply an offset to the camera. I’ve tried several ways, but they all seem to conflict with each other and result in not being able to move the camera at all when they’re both applied. Here’s my script:
local camera = workspace.CurrentCamera
local character = script.Parent
local root = character:WaitForChild("HumanoidRootPart")
local neck = character:FindFirstChild("Neck", true)
local waist = character:FindFirstChild("Waist", true)
local yOffsetNeck = neck.C0.Y
local yOffsetWaist = waist.C0.Y
local CFNew, CFAng, asin = CFrame.new, CFrame.Angles, math.asin
game:GetService("RunService").RenderStepped:Connect(function()
-- neck/torso follow camera
local cameraDirection = root.CFrame:toObjectSpace(camera.CFrame).LookVector
if neck then
neck.C0 = CFNew(0, yOffsetNeck, 0) * CFAng(0, -asin(cameraDirection.x / 2), 0) * CFAng(asin(cameraDirection.y / 2), 0, 0)
end
if waist then
waist.C0 = CFNew(0, yOffsetWaist, 0) * CFAng(0, -asin(cameraDirection.x / 2), 0) * CFAng(asin(cameraDirection.y / 2), 0, 0)
end
-- camera offset
camera.CFrame = root:GetPivot() * CFrame.new(3, 2, 5)
end)