Hi, I have a problem again lol.
For some reason unknown, my bools wont switch back off after I destroy a block.
I have the player set with a collider on each side to test if there’s a wall there, if so then I switch a bool on which disables the player from being able to keep walking towards the wall which stops it from getting stuck.
I also have destroyable walls and when standing next to a wall and destroying it, if its within the range of the colliders the bools wont switch off again until I climb onto a ladder or something else. My code for switching the bools on and off are as follows:
void OnTriggerStay2D (Collider2D other)
{
Collider2D collider = other.collider2D;
if (collider != null) {
string tag = other.collider2D.tag;
if (tag == "PLATFORM" || tag == "SOLID") {
if (Player_Control.onLadder == false) {
leftContact = true;
} else {
leftContact = false;
}
} else {
leftContact = false;
}
} else {
leftContact = false;
}
}
-
and to make sure it switches off:
void OnTriggerExit2D (Collider2D other)
{leftContact = false; }
Then all I have on the player is:
if ((lr > 0 && isRightSideContact.rightContact == false)) {//
walk = 1;
}
- With lr being the horizontal axis var.
So once I destroy a block while standing next to it the bool doesn’t switch back off. It works well otherwise. Could someone maybe point me in the right direction as to whats happening here??