How to make BoxColidier to have transparent side?

Hello everybody, this question is so hard to explain… So from this picture i think you will understand… So on the picture we have 1 field which is marked by BoxColidiers but 2D .
So when we have object inside of the field, object can’t go out from the field (For that i use BoxColidier2D). But when object coming from the outside of field, it can enter to the field :slight_smile: Please if you understand what should i do? A picture is attached…
Thank you!![![alt text][2]][3]

1 Answer

1

You can set the bottom collider as trigger, this let the obect pass, and with a simple script you can activate it when the object pass through, something like this:

void OnTriggerEnter2D(Collider2D other) {
    if(other.tag == "ObjectTagHere"){
    GetComponent<Collider2D>().isTrigger = false;
    }
   }

or

void OnTriggerExit2D(Collider2D other) {
        if(other.tag == "ObjectTagHere"){
        GetComponent<Collider2D>().isTrigger = false;
        }
       }

Not working :/ Do i need to check "Is trigger" or no?

Yes, you need to set as trigger the collider in the inspector by checking isTrigger, and put this script on that gameobject

Collider of my object or Collider of field? And i did BoxCollider2D

Collider of field, the collider of the object where your object need to pass through. And sorry i forgot you are using 2D so i edited the above code.