OnTriggerEnter2D will be called only if the object with that function has a Collider2D set to be a Trigger, the other object has a Collider2D, and at least one of the two objects has a Rigidbody2D.
Is your function being called? Use Debug.Log to find out where the code is failing.
yes i have collider set to intrigger for my coin. the two objects has a Collider2D, and atleast one of them have Rigidbody2D.
last time i opened my project i can collect them then when i opened it awhile ago it stops working. i dont know what just happened. the inspector for my coin is this:
If you get no messages at all, then yes your collider isn’t detecting the collision, or you’ve got your script in the wrong place perhaps.
Double check that you have both collider objects on GameObject layers that can interact. Are they both on Default layer, or perhaps custom layers? Physics Layer interaction is defined in Edit → Project Settings → Physics2D.
Make sure that this script is on the object or a parent of the collider. Make sure that the player’s collider is indeed a Trigger.
Can you take a pic of your player gameobject in the inspector (like you did with your coin), and a pic of your physics2D settings edit → projects settings → physics2D
The script that defines any physics callbacks like OnTriggerX and OnCollisionX, must be on the same object as the collider doing the colliding, or on a parent object.
I have a feeling the tutorial you followed may have done something differently than you have here. I actually have to go now but if this hasn’t been resolved by the time I’m back I’ll continue to help you.