function OrbitalCamera.Update(N,s)local g=tick()local b=g-N.lastUpdate local I=N.UserPanningTheCamera==true local D=workspace.CurrentCamera local Q=D.CFrame local n=D.Focus local o=PlayersService.LocalPlayer local V=D and D.CameraSubject local j=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 b>1 then N.lastCameraTransform=nil end if N.lastUpdate then local s=N:UpdateGamepad()if N:ShouldUseVRRotation()then N.RotateInput=N.RotateInput+N:GetVRRotationInput()else local g=math.min(.1,b)if s~=ZERO_VECTOR2 then I=true N.rotateInput=N.rotateInput+s*g end local D=0 if not(j or m)then D=D+(N.TurningLeft and-120 or 0)D=D+(N.TurningRight and 120 or 0)end if D~=0 then N.rotateInput=N.rotateInput+Vector2.new(math.rad(D*g),0)I=true end end end if I then N.lastUserPanCamera=tick()end local W=N:GetSubjectPosition()if W and(o and D)then if N.gamepadDollySpeedMultiplier~=1 then N:SetCameraToSubjectDistance(N.currentSubjectDistance*N.gamepadDollySpeedMultiplier)end local s=VRService.VREnabled n=s and N:GetVRFocus(W,b)or CFrame.new(W)local g=n.p if s and not N:IsInFirstPerson()then local s=N:GetCameraHeight()local b=W-D.CFrame.p local I=b.magnitude if I>N.currentSubjectDistance or N.rotateInput.x~=0 then local n=math.min(I,N.currentSubjectDistance)b=N:CalculateNewLookVector(b.unit*X1_Y0_Z1,Vector2.new(N.rotateInput.x,0))*n local o=g-b local V=D.CFrame.lookVector if N.rotateInput.x~=0 then V=b end local j=Vector3.new(o.x+V.x,o.y,o.z+V.z)N.RotateInput=ZERO_VECTOR2 Q=CFrame.new(o,j)+Vector3.new(0,s,0)end else N.curAzimuthRad=N.curAzimuthRad-N.rotateInput.x if N.useAzimuthLimits then N.curAzimuthRad=Util.Clamp(N.minAzimuthAbsoluteRad,N.maxAzimuthAbsoluteRad,N.curAzimuthRad)else N.curAzimuthRad=N.curAzimuthRad~=0 and math.sign(N.curAzimuthRad)*(math.abs(N.curAzimuthRad)%TAU)or 0 end N.curElevationRad=Util.Clamp(N.minElevationRad,N.maxElevationRad,N.curElevationRad+N.rotateInput.y)local s=N.currentSubjectDistance*(CFrame.fromEulerAnglesYXZ(-N.curElevationRad,N.curAzimuthRad,0)*UNIT_Z)local g=W+s Q=CFrame.new(g,W)N.rotateInput=ZERO_VECTOR2 end N.lastCameraTransform=Q N.lastCameraFocus=n if(j 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=g return Q,n 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 =
					Util.Clamp(self.minAzimuthAbsoluteRad, self.maxAzimuthAbsoluteRad, self.curAzimuthRad)
			else
				self.curAzimuthRad = (self.curAzimuthRad ~= 0)
						and (math.sign(self.curAzimuthRad) * (math.abs(self.curAzimuthRad) % TAU))
					or 0
			end

			self.curElevationRad =
				Util.Clamp(self.minElevationRad, self.maxElevationRad, self.curElevationRad + self.rotateInput.y)

			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
