In Unity 2D when space bar is pressed the user who has colli

In Unity 2D, when space bar is pressed, the user, who has collision detection, cannot collide with any other object while space is pressed down. How do I implement that?

Solution

I cannot answer this completely unless you give me the whole context but you can use Physics2D.IgnoreCollision() to ignore collision while space is pressed.

So, it will be something like..

Inside your loop..

    Physics.IgnoreCollision(object1, object2, ignore=true);

}

else{

    Physics.IgnoreCollision(object1, object2, ignore=false);

}

In Unity 2D, when space bar is pressed, the user, who has collision detection, cannot collide with any other object while space is pressed down. How do I implem

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site