Camera Angle Zoom Out Behiden

Made a camera Manipulation for zooming out of character head, the angle is off… the camera rotation is based off from input.delta
i don’t understand how its off from camera perspective, i want the camera Angle to always be behiden character when coming out.

CODE

local cameraRotation = Vector2.new(0, 0)
local cameraMouseRotateSpeed = 0.25
local cameraZoom = 8

--Update Per frame
local cameraRotationCFrame = CFrame.Angles(0, cameraRotation.X, 0) * CFrame.Angles(cameraRotation.Y, 0, 0)
camera.CFrame = cameraRotationCFrame + (hrp.Position+Vector3.new(0,1.5,0)) + cameraRotationCFrame * Vector3.new(0, 0, cameraZoom)
camera.Focus = camera.CFrame - Vector3.new(0, camera.CFrame.p.Y, 0)

--userInputService
function InputChanged(inputObject)
	if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
		local delta = inputObject.Delta
		local rotation = Vector2.new(delta.X, delta.Y)
		cameraRotation = cameraRotation - rotation * math.rad(cameraMouseRotateSpeed)
	end
end

1 Like

Funny took me half my day, and all i had to do was reset camera rotation.

1 Like