function CameraModule.ActivateCameraController(d,G,R)local q=nil if R~=nil then if R==Enum.CameraType.Scriptable then if d.activeCameraController then d.activeCameraController:Enable(false)d.activeCameraController=nil return end elseif R==Enum.CameraType.Custom then G=d:GetCameraMovementModeFromSettings()elseif R==Enum.CameraType.Track then G=Enum.ComputerCameraMovementMode.Classic elseif R==Enum.CameraType.Follow then G=Enum.ComputerCameraMovementMode.Follow elseif R==Enum.CameraType.Orbital then G=Enum.ComputerCameraMovementMode.Orbital elseif R==Enum.CameraType.Attach or R==Enum.CameraType.Watch or R==Enum.CameraType.Fixed then q=LegacyCamera else warn("\067\097\109\101\114\097\083\099\114\105\112\116 \101\110\099\111\117\110\116\101\114\101\100 \097\110 \117\110\104\097\110\100\108\101\100 \067\097\109\101\114\097\046\067\097\109\101\114\097\084\121\112\101 \118\097\108\117\101\058 ",R)end end if not q then if G==Enum.ComputerCameraMovementMode.Classic or G==Enum.ComputerCameraMovementMode.Follow or G==Enum.ComputerCameraMovementMode.Default or FFlagUserCameraToggle and G==Enum.ComputerCameraMovementMode.CameraToggle then q=ClassicCamera elseif G==Enum.ComputerCameraMovementMode.Orbital then q=OrbitalCamera else warn("\065\099\116\105\118\097\116\101\067\097\109\101\114\097\067\111\110\116\114\111\108\108\101\114 \100\105\100 \110\111\116 \115\101\108\101\099\116 \097 \109\111\100\117\108\101\046")return end end local E if not instantiatedCameraControllers[q]then E=q.new()instantiatedCameraControllers[q]=E else E=instantiatedCameraControllers[q]end if d.activeCameraController then if d.activeCameraController~=E then d.activeCameraController:Enable(false)d.activeCameraController=E d.activeCameraController:Enable(true)elseif not d.activeCameraController:GetEnabled()then d.activeCameraController:Enable(true)end elseif E~=nil then d.activeCameraController=E d.activeCameraController:Enable(true)end if d.activeCameraController then if G~=nil then d.activeCameraController:SetCameraMovementMode(G)elseif R~=nil then d.activeCameraController:SetCameraType(R)end end end
-- When supplied, legacyCameraType is used and cameraMovementMode is ignored (should be nil anyways)
-- Next, if userCameraCreator is passed in, that is used as the cameraCreator
function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraType)
	local newCameraCreator = nil

	if legacyCameraType ~= nil then
		--[[
			This function has been passed a CameraType enum value. Some of these map to the use of
			the LegacyCamera module, the value "Custom" will be translated to a movementMode enum
			value based on Dev and User settings, and "Scriptable" will disable the camera controller.
		--]]

		if legacyCameraType == Enum.CameraType.Scriptable then
			if self.activeCameraController then
				self.activeCameraController:Enable(false)
				self.activeCameraController = nil
				return
			end
		elseif legacyCameraType == Enum.CameraType.Custom then
			cameraMovementMode = self:GetCameraMovementModeFromSettings()
		elseif legacyCameraType == Enum.CameraType.Track then
			-- Note: The TrackCamera module was basically an older, less fully-featured
			-- version of ClassicCamera, no longer actively maintained, but it is re-implemented in
			-- case a game was dependent on its lack of ClassicCamera's extra functionality.
			cameraMovementMode = Enum.ComputerCameraMovementMode.Classic
		elseif legacyCameraType == Enum.CameraType.Follow then
			cameraMovementMode = Enum.ComputerCameraMovementMode.Follow
		elseif legacyCameraType == Enum.CameraType.Orbital then
			cameraMovementMode = Enum.ComputerCameraMovementMode.Orbital
		elseif
			legacyCameraType == Enum.CameraType.Attach
			or legacyCameraType == Enum.CameraType.Watch
			or legacyCameraType == Enum.CameraType.Fixed
		then
			newCameraCreator = LegacyCamera
		else
			warn("CameraScript encountered an unhandled Camera.CameraType value: ", legacyCameraType)
		end
	end

	if not newCameraCreator then
		if
			cameraMovementMode == Enum.ComputerCameraMovementMode.Classic
			or cameraMovementMode == Enum.ComputerCameraMovementMode.Follow
			or cameraMovementMode == Enum.ComputerCameraMovementMode.Default
			or (FFlagUserCameraToggle and cameraMovementMode == Enum.ComputerCameraMovementMode.CameraToggle)
		then
			newCameraCreator = ClassicCamera
		elseif cameraMovementMode == Enum.ComputerCameraMovementMode.Orbital then
			newCameraCreator = OrbitalCamera
		else
			warn("ActivateCameraController did not select a module.")
			return
		end
	end

	-- Create the camera control module we need if it does not already exist in instantiatedCameraControllers
	local newCameraController
	if not instantiatedCameraControllers[newCameraCreator] then
		newCameraController = newCameraCreator.new()
		instantiatedCameraControllers[newCameraCreator] = newCameraController
	else
		newCameraController = instantiatedCameraControllers[newCameraCreator]
	end

	-- If there is a controller active and it's not the one we need, disable it,
	-- if it is the one we need, make sure it's enabled
	if self.activeCameraController then
		if self.activeCameraController ~= newCameraController then
			self.activeCameraController:Enable(false)
			self.activeCameraController = newCameraController
			self.activeCameraController:Enable(true)
		elseif not self.activeCameraController:GetEnabled() then
			self.activeCameraController:Enable(true)
		end
	elseif newCameraController ~= nil then
		self.activeCameraController = newCameraController
		self.activeCameraController:Enable(true)
	end

	if self.activeCameraController then
		if cameraMovementMode ~= nil then
			self.activeCameraController:SetCameraMovementMode(cameraMovementMode)
		elseif legacyCameraType ~= nil then
			-- Note that this is only called when legacyCameraType is not a type that
			-- was convertible to a ComputerCameraMovementMode value, i.e. really only applies to LegacyCamera
			self.activeCameraController:SetCameraType(legacyCameraType)
		end
	end
end
