I am using Edge Collider 2D with Platform Effector 2D. It works fine, the character does not collide with the platform when coming from under it, but that DOES call OnCollisionEnter2D on the character.
Is it supposed to work like this?
It would be better if it did not call OnCollisionEnter2D, wouldn’t it?
That’s by design. You still may want to know if you touch the colliders or enter triggers no matter what the effector behaviour that may be associated with it is. Don’t forget, they’re still stock colliders, they just get additional behaviour.
If you want to somehow distinguish them from other colliders on the same GameObject that are not used by the effector then simply check that property before processing it.
I am making an endless runner game. As the player character is jumping and OnCollisionEnter2D is triggered in its script, I change animation state from Jumping to Walking again.
But if the player jumps from below a platform that has an Edge Collider 2D with Platform Effector 2D and crosses it, OnCollisionEnter2D is called and the animation changes mid-air.
As a workaround I added a third condition: if rigidbody2D.velocity.y <= 0, so I know the character is already falling from the jump.
Actually, looks like I completely missed your point (for some unknown reason), sorry for that.
So you’re talking about not wanting callbacks when the contact is disabled.
When you get the contact (Collision2D) simply check the ‘enabled’ property: [Unity - Scripting API: Collision2D.enabled](http://Actually, I think I may have missed your point for (some unknown reason), sorry for that. So you’re talking about not wanting callbacks when the contact is disabled but instead of that, you already get provided information about if the contact was disabled: Unity - Scripting API: Collision2D.enabled)
This will be false when the one-way is in-effect i.e. the object is passing through the platform and true under all other circumstances.
I also have the same problem i am making a 2d top down shooter and i want to make cover where you can only shoot trough one way but the bullet detects collision and destroys itself (like it hit a normal wall) i tried to fix this by checking if collision2d.enabled is true but it still detected collision here is my script