- Home /
Why is my 2D collision not working?
So I have a rigid body 2D and a circle collider 2D on my player sprite (the green one) and a Polygon Collider 2D on an other (player is standing on an orange thingy). Both are triggers. To test if they work I added a debug line but if I walk over the other collider nothing happens. On the Z-axis the two sprites don't have the same value, but that shouldn't matter in 2D mode right?
void OnCollisionEnter2D(Collision2D col) {
Debug.Log ("It works!")
}
I really can't see what I am doing wrong!
Thanks, been a while since I worked with Unity forgot about that!
Answer by Mubanga · Aug 23, 2014 at 02:05 PM
Tanoshimi answered my question in a comment:
"'Both are triggers' is what you're doing wrong. If this is the case, you want OnTriggerEnter2D, not OnCollisionEnter2D."
Your answer
![](https://koobas.hobune.stream/wayback/20220613161327im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D box colliders not touching but are colliding, how to fix? 0 Answers
Weapon System with collide detection (Helps with script pls)!!! 0 Answers
Why is my collision script not working? 1 Answer
OnTriggerStay2D only detecting trigger collisions while moving 3 Answers
Detecting collisions between objects from another c# script 1 Answer