Hello,
I’ve search the forums and found similar topics but haven’t found on the helps with this specific issue. I am trying to get a button to be interactable once the player comes into contact with a collider (set to a trigger)
Below is the code I have:
[RequireComponent(typeof(Button))]
public class SpellBook : MonoBehaviour
{
public Button disarm;
public Sprite blockA;
public bool interactable;
public GameObject trigA;
private int counter = 0;
// public event TriggerEventDelegate triggerEvent;
// Start is called before the first frame update
void Start()
{
disarm = GetComponent<Button>();
disarm.interactable = false;
//disarm.Sprite.enabled = false;
}
public void OnMouseDown()
{
DestroyObject(GameObject.FindGameObjectWithTag("Trap"));
}
public void OnTriggerEnter()
{
//disarm = GameObject.FindGameObjectWithTag("Prop");
disarm.interactable = !disarm.interactable;
}
}