I'm trying to create a third person camera and cannot get it to rotate around the player properly. What I am doing is taking the mouse.Delta as a way to add or subtract the angle of rotation. My problem is it will not rotate around the player, and if I allow the y axis to be rotated, it will be able to be rotated to unusable angles (It can flip upside-down and whatnot) I have tried to add and subtract the Z according to the rotation amount but that probed unreliable. I also tried to use CFrame:toObjectSpace() and couldn't get that to work.
My code:
--Camera update-- game:GetService("RunService").RenderStepped:connect(function() if player.Self == nil then return end cam.CoordinateFrame = player.Self.Head.CFrame*CFrame.new(0,1,7)*camera.offset end) --Input-- inp.InputChanged:connect(function(io) if io.UserInputType == Enum.UserInputType.MouseMovement then camera.offset = camera.offset*CFrame.Angles(0,-math.rad(io.Delta.x/10),0) end end)
Watch this, it explains how to force first and third person cameras and explains how they work: https://www.youtube.com/watch?v=kyJZxVJZpHg