Okay, so I’m currently making a 1st-person dungeon crawl, and I’m having some issues with collision with the wall.
Basically I have a character with four collision boxes around him. Front, back, left, and right. I have it set up so that onBeginOverlap, it turns a variable for that side on. (Wall in front makes variable isFrontBlocked = 1, etc…). It worked great until I put in the collision boxes on the side.
Essentially, I’ve got tiled walls, and when the box on the left or right passes “between” it turns the isBlocked variables off:
Sorry for my terrible paint drawing!
But my guess is that it detects it’s overlapping a new tile, so it sets isBlocked to true while it’s still already true, and then it get’s turned off as it ends the overlap from the previous wall tile.
So I thought maybe instead of a boolean, I’d use an integer:
onOverlapBegin: betweenLeft += 1
onOverlapEnd: betweenLeft -= 1
So the function would be if betweenLeft >= 1, you cannot move left. But it still doesn’t work. Sometimes it seems that it will add and then subtract, and other times it will subtract then add. Making the betweenLeft variable get some funky numbers.
What’s the best way to go about this?