Answer the question
In order to leave comments, you need to log in
How to return the previous state of an object after using Physics2D.IgnoreCollision?
I ran into such a problem that the Physics2D.IgnoreCollision, Physics2D.GetIgnoreCollision, Physics2D.IgnoreLayerCollision tags work only in one direction and I don’t know, in fact, how you can return the previous state of the object when it reacts to all collisions. Or do I need to change the script scheme?
Answer the question
In order to leave comments, you need to log in
IgnoreCollision can be reset by turning off the collider, as it is written in the documentation:
IgnoreLayerCollision apparently changes the interaction matrix of layers, and it cannot be canceled so easily. Either remember what you ignored, or save the entire matrix with GetIgnoreLayerCollision and GetLayerCollisionMask , and overwrite the current matrix in its entirety when needed.
You can also destroy everything in layers and transfer either moving objects between layers, or obstacles. IgnoreCollision is more of a crutch for special situations, you should not use it everywhere.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question