I’ve placed in the scene an object with a trigger and I want the console sends me a message detecting if the player is in or out of the trigger when I click a button . When
Try:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MapDetect : MonoBehaviour {
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
Debug.Log ("Map ON");
}
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
Debug.Log ("Map OFF");
}
}
}
This will switch it on when you enter and off when you exit (althout all it does right now is print the result).
Hope it helps.