function OrbitalCamera.Update(n,w)local a=tick()local g=a-n.lastUpdate local Q=n.UserPanningTheCamera==true local I=workspace.CurrentCamera local C=I.CFrame local W=I.Focus local P=PlayersService.LocalPlayer local V=I and I.CameraSubject local M=V and V:IsA("\086\101\104\105\099\108\101\083\101\097\116")local m=V and V:IsA("\083\107\097\116\101\098\111\097\114\100\080\108\097\116\102\111\114\109")if n.lastUpdate==nil or g>1 then n.lastCameraTransform=nil end if n.lastUpdate then local w=n:UpdateGamepad()if n:ShouldUseVRRotation()then n.RotateInput=n.RotateInput+n:GetVRRotationInput()else local a=math.min(.1,g)if w~=ZERO_VECTOR2 then Q=true n.rotateInput=n.rotateInput+w*a end local I=0 if not(M or m)then I=I+(n.TurningLeft and-120 or 0)I=I+(n.TurningRight and 120 or 0)end if I~=0 then n.rotateInput=n.rotateInput+Vector2.new(math.rad(I*a),0)Q=true end end end if Q then n.lastUserPanCamera=tick()end local k=n:GetSubjectPosition()if k and(P and I)then if n.gamepadDollySpeedMultiplier~=1 then n:SetCameraToSubjectDistance(n.currentSubjectDistance*n.gamepadDollySpeedMultiplier)end local w=VRService.VREnabled W=w and n:GetVRFocus(k,g)or CFrame.new(k)local a=W.p if w and not n:IsInFirstPerson()then local w=n:GetCameraHeight()local g=k-I.CFrame.p local Q=g.magnitude if Q>n.currentSubjectDistance or n.rotateInput.x~=0 then local W=math.min(Q,n.currentSubjectDistance)g=n:CalculateNewLookVector(g.unit*X1_Y0_Z1,Vector2.new(n.rotateInput.x,0))*W local P=a-g local V=I.CFrame.lookVector if n.rotateInput.x~=0 then V=g end local M=Vector3.new(P.x+V.x,P.y,P.z+V.z)n.RotateInput=ZERO_VECTOR2 C=CFrame.new(P,M)+Vector3.new(0,w,0)end else n.curAzimuthRad=n.curAzimuthRad-n.rotateInput.x if n.useAzimuthLimits then n.curAzimuthRad=math.clamp(n.curAzimuthRad,n.minAzimuthAbsoluteRad,n.maxAzimuthAbsoluteRad)else n.curAzimuthRad=n.curAzimuthRad~=0 and math.sign(n.curAzimuthRad)*(math.abs(n.curAzimuthRad)%TAU)or 0 end n.curElevationRad=math.clamp(n.curElevationRad+n.rotateInput.y,n.minElevationRad,n.maxElevationRad)local w=n.currentSubjectDistance*(CFrame.fromEulerAnglesYXZ(-n.curElevationRad,n.curAzimuthRad,0)*UNIT_Z)local a=k+w C=CFrame.new(a,k)n.rotateInput=ZERO_VECTOR2 end n.lastCameraTransform=C n.lastCameraFocus=W if(M or m)and V:IsA("\066\097\115\101\080\097\114\116")then n.lastSubjectCFrame=V.CFrame else n.lastSubjectCFrame=nil end end n.lastUpdate=a return C,W end return OrbitalCamera
-- [[ Update ]]--
function OrbitalCamera:Update(dt)
	local now = tick()
	local timeDelta = (now - self.lastUpdate)
	local userPanningTheCamera = (self.UserPanningTheCamera == true)
	local camera = workspace.CurrentCamera
	local newCameraCFrame = camera.CFrame
	local newCameraFocus = camera.Focus
	local player = PlayersService.LocalPlayer
	local cameraSubject = camera and camera.CameraSubject
	local isInVehicle = cameraSubject and cameraSubject:IsA("VehicleSeat")
	local isOnASkateboard = cameraSubject and cameraSubject:IsA("SkateboardPlatform")

	if self.lastUpdate == nil or timeDelta > 1 then
		self.lastCameraTransform = nil
	end

	if self.lastUpdate then
		local gamepadRotation = self:UpdateGamepad()

		if self:ShouldUseVRRotation() then
			self.RotateInput = self.RotateInput + self:GetVRRotationInput()
		else
			-- Cap out the delta to 0.1 so we don't get some crazy things when we re-resume from
			local delta = math.min(0.1, timeDelta)

			if gamepadRotation ~= ZERO_VECTOR2 then
				userPanningTheCamera = true
				self.rotateInput = self.rotateInput + (gamepadRotation * delta)
			end

			local angle = 0
			if not (isInVehicle or isOnASkateboard) then
				angle = angle + (self.TurningLeft and -120 or 0)
				angle = angle + (self.TurningRight and 120 or 0)
			end

			if angle ~= 0 then
				self.rotateInput = self.rotateInput + Vector2.new(math.rad(angle * delta), 0)
				userPanningTheCamera = true
			end
		end
	end

	-- Reset tween speed if user is panning
	if userPanningTheCamera then
		self.lastUserPanCamera = tick()
	end

	local subjectPosition = self:GetSubjectPosition()

	if subjectPosition and player and camera then
		-- Process any dollying being done by gamepad
		-- TODO: Move this
		if self.gamepadDollySpeedMultiplier ~= 1 then
			self:SetCameraToSubjectDistance(self.currentSubjectDistance * self.gamepadDollySpeedMultiplier)
		end

		local VREnabled = VRService.VREnabled
		newCameraFocus = VREnabled and self:GetVRFocus(subjectPosition, timeDelta) or CFrame.new(subjectPosition)

		local cameraFocusP = newCameraFocus.p
		if VREnabled and not self:IsInFirstPerson() then
			local cameraHeight = self:GetCameraHeight()
			local vecToSubject = (subjectPosition - camera.CFrame.p)
			local distToSubject = vecToSubject.magnitude

			-- Only move the camera if it exceeded a maximum distance to the subject in VR
			if distToSubject > self.currentSubjectDistance or self.rotateInput.x ~= 0 then
				local desiredDist = math.min(distToSubject, self.currentSubjectDistance)

				-- Note that CalculateNewLookVector is overridden from BaseCamera
				vecToSubject = self:CalculateNewLookVector(
					vecToSubject.unit * X1_Y0_Z1,
					Vector2.new(self.rotateInput.x, 0)
				) * desiredDist

				local newPos = cameraFocusP - vecToSubject
				local desiredLookDir = camera.CFrame.lookVector
				if self.rotateInput.x ~= 0 then
					desiredLookDir = vecToSubject
				end
				local lookAt = Vector3.new(newPos.x + desiredLookDir.x, newPos.y, newPos.z + desiredLookDir.z)
				self.RotateInput = ZERO_VECTOR2

				newCameraCFrame = CFrame.new(newPos, lookAt) + Vector3.new(0, cameraHeight, 0)
			end
		else
			-- self.RotateInput is a Vector2 of mouse movement deltas since last update
			self.curAzimuthRad = self.curAzimuthRad - self.rotateInput.x

			if self.useAzimuthLimits then
				self.curAzimuthRad =
					math.clamp(self.curAzimuthRad, self.minAzimuthAbsoluteRad, self.maxAzimuthAbsoluteRad)
			else
				self.curAzimuthRad = (self.curAzimuthRad ~= 0)
						and (math.sign(self.curAzimuthRad) * (math.abs(self.curAzimuthRad) % TAU))
					or 0
			end

			self.curElevationRad =
				math.clamp(self.curElevationRad + self.rotateInput.y, self.minElevationRad, self.maxElevationRad)

			local cameraPosVector = self.currentSubjectDistance
				* (CFrame.fromEulerAnglesYXZ(-self.curElevationRad, self.curAzimuthRad, 0) * UNIT_Z)
			local camPos = subjectPosition + cameraPosVector

			newCameraCFrame = CFrame.new(camPos, subjectPosition)

			self.rotateInput = ZERO_VECTOR2
		end

		self.lastCameraTransform = newCameraCFrame
		self.lastCameraFocus = newCameraFocus
		if (isInVehicle or isOnASkateboard) and cameraSubject:IsA("BasePart") then
			self.lastSubjectCFrame = cameraSubject.CFrame
		else
			self.lastSubjectCFrame = nil
		end
	end

	self.lastUpdate = now
	return newCameraCFrame, newCameraFocus
end

return OrbitalCamera
