So I have a variable called "direction" which describes the direction my player is facing, duh. The problem is that I take in this variable when the player collides with something and if the player changes directions while inside an object weird things happen. For example, the player passes through a door (its a platformer) but if it switches directions the door gets flipped horizontally.
How do I fix this?