function CameraModule.ActivateCameraController(h,F,Q)local q=nil if Q~=nil then if Q==Enum.CameraType.Scriptable then if h.activeCameraController then h.activeCameraController:Enable(false)h.activeCameraController=nil return end elseif Q==Enum.CameraType.Custom then F=h:GetCameraMovementModeFromSettings()elseif Q==Enum.CameraType.Track then F=Enum.ComputerCameraMovementMode.Classic elseif Q==Enum.CameraType.Follow then F=Enum.ComputerCameraMovementMode.Follow elseif Q==Enum.CameraType.Orbital then F=Enum.ComputerCameraMovementMode.Orbital elseif Q==Enum.CameraType.Attach or Q==Enum.CameraType.Watch or Q==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 ",Q)end end if not q then if F==Enum.ComputerCameraMovementMode.Classic or F==Enum.ComputerCameraMovementMode.Follow or F==Enum.ComputerCameraMovementMode.Default or F==Enum.ComputerCameraMovementMode.CameraToggle then q=ClassicCamera elseif F==Enum.ComputerCameraMovementMode.Orbital then q=OrbitalCamera else return end end local z=h:ShouldUseVehicleCamera()if z then q=VehicleCamera end local o if not instantiatedCameraControllers[q]then o=q.new()instantiatedCameraControllers[q]=o else o=instantiatedCameraControllers[q]if o.Reset then o:Reset()end end if h.activeCameraController then if h.activeCameraController~=o then h.activeCameraController:Enable(false)h.activeCameraController=o h.activeCameraController:Enable(true)elseif not h.activeCameraController:GetEnabled()then h.activeCameraController:Enable(true)end elseif o~=nil then h.activeCameraController=o h.activeCameraController:Enable(true)end if h.activeCameraController then if F~=nil then h.activeCameraController:SetCameraMovementMode(F)elseif Q~=nil then h.activeCameraController:SetCameraType(Q)end end end

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
			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

	local isVehicleCamera = self:ShouldUseVehicleCamera()
	if isVehicleCamera then
		newCameraCreator = VehicleCamera
	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]
		if newCameraController.Reset then
			newCameraController:Reset()
		end
	end
	
	if self.activeCameraController then
		-- deactivate the old controller and activate the new one
		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
		-- only activate the new controller
		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
