Third person camera?
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:
02 | game:GetService( "RunService" ).RenderStepped:connect( function () |
03 | if player.Self = = nil then return end |
04 | cam.CoordinateFrame = player.Self.Head.CFrame*CFrame.new( 0 , 1 , 7 )*camera.offset |
07 | inp.InputChanged:connect( function (io) |
08 | if io.UserInputType = = Enum.UserInputType.MouseMovement then |
09 | camera.offset = camera.offset*CFrame.Angles( 0 ,-math.rad(io.Delta.x/ 10 ), 0 ) |