EDIT: PROBLEM SOLVED ALREADY!
I uploaded a screenshot (in wireframe) so you can see where my mesh is (blue), and where my trigger is (green, naturally)
From some reason the trigger is only activated when the Player enters the mesh of the box (i.e. literally steps into the box).
IsTrigger is checked. And here is the script:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class InteractionAppear : MonoBehaviour {
public Camera ToolboxCam;
public Camera MainCam;
public Button InteractButton;
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Player")
{
Debug.Log("Da!");
InteractButton.GetComponent<CanvasGroup>().alpha = 1;
if (Input.GetKey(KeyCode.E))
{
MainCam.GetComponent<Camera>().enabled = false;
ToolboxCam.GetComponent<Camera>().enabled = true;
}
}
}
void OnTriggerExit(Collider col)
{
if (col.gameObject.tag == "Player")
{
InteractButton.GetComponent<CanvasGroup>().alpha = 0;
Debug.Log("net!");
}
}
}
I also get a strange warning:
There are inconsistent line endings in the ‘Assets/Scripts/InteractionAppear.cs’ script. Some are Mac OS X (UNIX) and some are Windows.
This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands.