I’m using the Layer Collision Matrix with Physics2D to allow certain objects to pass through each other and have certain objects collide. The player can switch between layers to choose which objects to pass through and which to collide with.
Layer 8 and Layer 9 are set to not collide with each other. If my player is on Layer 8 and jumps on an object in Layer 8, he will stand on that object. When changing the layer of the player to Layer 9, he should fall through immediately, but he doesn’t. He can walk left and right on the Layer 8 object while he is in layer 9. If I leave the Layer 8 object by jumping, the Player on Layer 9 will then fall through like it should instead of landing.
For example:
Object: Layer 8
Player: Layer 8
Player stands on object → Good, since both are on layer 8.
Player changes to layer 9 → Player stays in collision with layer 8 object, even though he shouldn’t.
Player (still in Layer 9) manually leaves the object he’s colliding in by jumping → Player falls through object, which is ideal.
My Debug.log shows that he’s staying in collision with the layer 8 object even when he’s moved to layer 9. Calling IgnoreLayerCollision does nothing (it’s already set to ignore in the matrix anyway). Calling OnCollisionExit2D in OnCollisionStay2D does nothing either. Adding small nudges via a Vector2 does nothing. Is there a workaround, or am I missing something?
There are two other users that have experienced the same thing with no answers for them:
http://answers.unity3d.com/questions/612288/when-changing-a-gameobjects-layer-the-physics-coll.html
and (Second to last post by NioFox)-
http://forum.unity3d.com/threads/211215-Bug-on-physic2D-layers
Any help on the matter would be awesome. Thanks.