Hi I’m trying to make an object passable whenever the player passes it from the bottom but solid when it is on top of it. The thing is that when the player touches the object from the bottom everything works just as it should, but when it exits the collider the object won’t turn into a solid again. Here is the code:
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "Passable" && hasGoneThrough == true)
{
Debug.Log("collided");
col.gameObject.GetComponent<BoxCollider2D>().isTrigger = true;
}
}
void OnCollisionExit2D(Collision2D other)
{
if (other.gameObject.tag == "Passable")
{
Debug.Log("uncollided");
other.gameObject.GetComponent<BoxCollider2D>().isTrigger = false;
}
}