I have two objects in my scene, one which only has a BoxCollider2D (the Column class) and the second object has a Rigibody2D as well as its own BoxCollider2D (Player class).
I added a script to the first object to have an OnCollisionEnter2D. I see it gets triggered when my second object collides with it, and it bounces my 2nd object back when it tries to enter.
I do see my OnCollisionEnter2D method getting called. But if I move my 2nd object again to my first object it gets bounced back again, however I don’t see my OnCollisionEnter2D method getting called the 2nd time.
I also see that OnCollisionExit2D was never called even though I clearly saw on the scene that it pushed the player out of the BoxCollider2D lines
you might be getting a little over fancy for what you need, maybe try this instead but make sure not to get rid of your code in case it happens to be more of what you want.
i would set a bunch of bools for my criteria in the script for the wall object itself since you’re controlling it’s collider
public bool first = false;
public bool second = false;
//then in my update i would just have it check to see if all those bools are now true
void Update()
{
CheckCollider();
}
//to make it look cleaner i would make a method that i would call in the update rather than all that jumbled code in the Update Method
void CheckCollider()
{
if (first == true && second == true)
{
GetComponent<Collider2D>().enabled = false;
}
else
{
return;
}
}
you’ll need to set your scripts and methods where they go for making that bool become true also you can have as many bools as you want