Adventure Creator Wikia

Hotspots have a Limit to camera field, which causes them to only be active when the chosen camera is active.  However, only one camera can be selected.   This script allows you to define multiple limiting cameras for a given Hotspot, as well as negate the effect - to prevent a Hotspot from being interactive if a given camera is active.

To use it:

  1. Paste the code in a C# script named MultiLimitHotspotCamera
  2. Set the script's Script Execution Order to a negative value
  3. Attach it to a Hotspot, and fill out the fields in the Inspector.
  4. Optional: To negate the effect, check "Negate Effect" and assign an unused GameCamera in the "Dummy Cam" field.

MultiLimitHotspotCamera.cs:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using AC;

public class MultiLimitHotspotCamera : MonoBehaviour
{

	[SerializeField] private Hotspot hotspot = null;
	[SerializeField] private List<_Camera> limitToCameras = new List<_Camera>();
	[SerializeField] private bool negateEffect = false;
	[SerializeField] private _Camera dummyCam = null;

	private void OnEnable () { EventManager.OnSwitchCamera += SwitchCamera; }
	private void OnDisable () { EventManager.OnSwitchCamera -= SwitchCamera; }

	private void SwitchCamera (_Camera old, _Camera newCamera, float transitionTime)
	{
		if (negateEffect)
		{
			if (limitToCameras.Contains (newCamera))
			{
				hotspot.limitToCamera = dummyCam;
			}
			else
			{
				hotspot.limitToCamera = newCamera;
			}
		}
		else
		{
			if (limitToCameras.Contains (newCamera))
			{
				hotspot.limitToCamera = newCamera;
			}
		}
	}

}