Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make the camera stay in front of the head at all times?

Asked by 2 years ago

I have a LocalScript where the camera follows the head instead of the HumanoidRootPart. Here is the script:

while true do
local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:wait()
local hum = char:WaitForChild("Humanoid")
local rootpart,head = char:WaitForChild("HumanoidRootPart"),char:WaitForChild("Head")
game:GetService("RunService"):BindToRenderStep("CameraOffset",Enum.RenderPriority.Camera.Value-1,function()
    hum.CameraOffset = (rootpart.CFrame+Vector3.new(0,1.5,0)):pointToObjectSpace(head.CFrame.p)
end)
wait(0.01)
end

It works fine, so i implemented a script that allows to see your body in first person but then this happens:

https://ibb.co/GCXz1CL

So i edited the offset here:

    hum.CameraOffset = (rootpart.CFrame+Vector3.new(1,1.5,0)):pointToObjectSpace(head.CFrame.p)

But then this happens:

https://gfycat.com/somberwearycornsnake

There is a way to solve this problem so that the camera stays in front of the head at all times?

1
use CFrame.LookVector not the Vector3 Xapelize 2658 — 2y

Answer this question