Issue with OnTriggerEnter()

I’m fairly new to unity and am basically just learning the simple stuff, sorry in advance if this is a dumb mistake, and for the inevitable formatting errors.

I have a player in a 2d game, that will walk over a flower that has a Box Collider 2d with IsTrigger checked, and then the following script on the player object should send a message to let me know the player collided with the trigger

using UnityEngine;

public class Itempickupchecker : MonoBehaviour
{
void OnTriggerEnter(Collider other)
{
Debug.Log("Flower picked up");
}

}

however when the player walks over the flower nothing happens. The collider on the flower is this:


and the colliders on the player are these:

I think the issue is either a typo, something wrong with the colliders/rigidbody or me using some function or component meant for a 3d game perhaps, but im not really too sure

thanks for any help

Are they both on the same layer?

I believe so, if i make the flower’s collider not a trigger then the player can bump into it and stand on it etc

OnTriggerEnter() is the 3D version. You want this:

1 Like

You need to use OnTriggerEnter2D

1 Like

Thanks!

Woops, I had missed that one… Shame on me. :frowning: