Adventure Creator Wikia
Advertisement

When Player-switching is enabled, this script allows you to limit a Hotspot's interactivity to specific Players characters. To use it:

  1. Create a new C# script named PlayerSpecificHotspot.cs, and paste in the code below
  2. Add the new Player Specific Hotspot component to a Hotspot, and add the IDs of all Players that can interact with it. (A Player's ID is listed next to their prefab field in the Settings Manager)


PlayerSpecificHotspot.cs:

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

public class PlayerSpecificHotspot : MonoBehaviour
{

	public List<int> enableForPlayerIDs;
	private Hotspot hotspot;

	void OnEnable ()
	{
		hotspot = GetComponent<Hotspot> ();
		EventManager.OnSetPlayer += SetNewPlayer;
		EventManager.OnAfterChangeScene += OnAfterChangeScene;
	}

	void OnDisable ()
	{
		EventManager.OnSetPlayer -= SetNewPlayer;
		EventManager.OnAfterChangeScene -= OnAfterChangeScene;
	}

	void SetNewPlayer (Player player)
	{
		ReactToID (player.ID);
	}

	void OnAfterChangeScene (LoadingGame loadingGame)
	{
		if (KickStarter.player)
			ReactToID (KickStarter.player.ID);
	}

	void ReactToID (int playerID)
	{
		if (enableForPlayerIDs.Contains (playerID))
		{
			hotspot.TurnOn ();
		}
		else
		{
			hotspot.TurnOff ();
		}
	}

}
Advertisement