How do I do anything with a collision event?

Hello,

I have been trying to get it so that the player object can collect a coin (In 2D). I have already successfully used a particle system to create a gun and have it so that when it hits an enemy it sends a messages to call damage. So when I went to try and do a similar thing with 2 GameObjects instead of a particle and a GameObject I figured it’d be pretty much the same, apparently not? anyways this is my problem.

I have the player and a coin, both have Rigidbodies and 2D colliders, and I haven’t made either of them Kinematic, mostly because I want them to both still have physics. What I’m asking is how do I use the collision to get information / pass information on. I tried using OnCollisionEnter(Collision collision) and then in there trying to Debug.Log(collision.gameObject.tag) or a million different variations of that but I can’t seem to get anything to print to console. Even if it’s just a string when any object collides with it.

Sorry if this is a bit of a ramble, I’m trying to describe as much of the situation and what I’ve done as possible because I don’t really know where the error could be. Please help, thanks in advance :slight_smile:

Here’s a checklist for you

  1. Do both of the objects colliding have some kind of collider attached?

  2. Does one of the objects have a rigidbody attached?

  3. Make sure you aren’t checking collision.gameObject.tag make sure you are checking collision.collider.tag

  4. Both colliders must have “isTrigger” unchecked

  5. If you are using 2D Colliders, make sure you have a 2d rigidbody on one object

  6. if you are using 2d, then make sure it looks like this

`void OnCollisionEnter2D(Collision2D col)
{

}`