I was attempting to create a simple button prompt where when you are inside a 2d box colider it will give you the option to press the button within that range, below is the short code used to test this.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
public class ButtonScript : MonoBehaviour
{
private void OnCollisionEnter2D(Collision2D collision)
{
Debug.Log("ENTER");
}
private void OnCollisionStay2D(Collision2D collision)
{
Debug.Log("Stay");
if (collision.gameObject.tag == "Player")
{
Debug.Log("PLayer Detected");
if (Input.GetKeyDown(KeyCode.E)) {
Debug.Log("E pressed");
}
}
}
}
However this does not output any Debug Messages at all. Maybe i have a misundestanding of the Is Trigger function and colliders in general but when i have it turned off it does nothing, when i have it on it acts as a box (which i dont want) but when i push againsts the box it will send out the debug messages.