Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Disable psychics collisions and leave trigger detection in Unity2d

I have two objects with RigidBody2D and two BoxColliders (2D) first is trigger second is collidable
i want to turn off psychical colliding between this two objects (i need it to objects stay at ground)
and leave trigger detection working in code.

I tried to Exclude layers in rigid body but it also turned off trigger detection in code
For example:
I have script

...
private void OnTriggerEnter2D(Collision2D coll) 
{
    Debug.Log("Triggered");
}

Before changing excluding layer it works well but colliding is on
When i change everything turnes off (trigger detection and collision)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Anyone knows how to achieve this?

>Solution :

Have you tried using layers? To achieve objects with box colliders that do not physically collide but still detect trigger events, you need to use different layers for the objects and adjust the collision matrix.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading