Y
Y
Yura Berezovsky2017-04-05 22:58:14
C++ / C#
Yura Berezovsky, 2017-04-05 22:58:14

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?082f7c9cde4646e49c52bda98dc2956b.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2017-04-06
@Jurajkeee

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 question

Ask a Question

731 491 924 answers to any question