Cursor and 2d Collider Interactions

Hello,

I’d like to detect when the player’s mouse pointer enters and exits a 2d box collider. I’m really not sure where to start here.

I’ve done some things like add a Physics 2D Raycaster to the main camera, add an Event Trigger to the object w/ collider, and used the method like this:

    public void OnPointerEnter(PointerEventData eventData)
    {
        Debug.Log("hello world");
    }

Unfortunately, I’m having nothing happen.

Any advice or comments would be appreciated.

Thanks for reading and TIA if you happen to leave a reply <3

Thanks to anyone who read this, and sorry to be a bother. I got help by looking at the following video

Mistake is I needed to add rigidbody2D to the object and use OnMouseEnter. And I had no need for raycaster or event trigger. Sorry again to be a bother and sorry if this post was in the wrong location.

1 Like