I need a system for my game where the player is in first person but they can't control their camera and instead it just follows their head. I couldn't find any camera types that let me do that, so I scripted my own system.
My system tweens the camera to the head's position every frame by using RenderStepped. Everything works fine apart from the second CFrame argument, the one where I have to put in where the camera should be looking.
CFrame = CFrame.new(char.Head.CFrame.Position, char.Head.CFrame.lookVector)
The first argument works great and as expected, but the second argument makes the camera constantly look at (0, 0, 0), and when I print out the lookVector of the head, it prints out seemingly random numbers that decrease as I get closer to (0, 0, 0).
I'm not sure if I'm understanding lookVector correctly or if I'm doing it completely wrong, but some guidance would be appreciated.
I think the problem is that you're only using the lookVector for the camera to focus on. To my knowledge, lookVector is a unit vector, which means that all vector3 values x,y,z are between 0 and 1 with a magnitude of 1. Since the CFrame lookAt position is only at the lookVector, it automatically starts at the origin, and your camera ends up looking towards the origin.
To fix this I think you can just add the character's head position to the lookVector.
CFrame = CFrame.new(char.Head.CFrame.Position, char.Head.CFrame.Position + char.Head.CFrame.lookVector)
Not sure if this works but hopefully it helped :)
Update:
--This is a localscript in startgui local player = game.Players.LocalPlayer local char = player.Character local camera = game.Workspace.CurrentCamera while true do if char then local head = char:WaitForChild("Head") camera.CFrame = CFrame.new(head.CFrame.Position, head.CFrame.Position + head.CFrame.lookVector) end wait(0.05) end
I also put a folder in starter character scripts called animate which removes the animations, and this stopped the spinning.