New week, new chance of fixing collision. I’m afraid it will haunt me for a long time haha. But at least I figured out that increasing the tile region doesn’t fix the issue. It is weird that the issue happens less often. So their could still be something going wrong with the tile region. But I am going to wait until I have some debug drawing tools for that.
That means that I need to look somewhere else to find the solution. Or rather what the problem actually is. It doesn’t happen consistantly, which bothers me a lot. But I went back to the rotation code and turned it on again. It may have nothing to do with the problem I am having. However it reminded me that some weird behaviour is going on here.
When the entity, in this case the player, is rotating, it won’t have any effect on the velocity. That means only the collider and the graphic are rotating. The collider is the thing actually interacting with the world. Nothing else happens when an entity is rotated.
Which suggests that, if the entity hits a wall when moving down. It will move down in a straight line and will move along the wall if that is possible. In the game however, the entity gets stuck and seems to move in the direction of the rotation. As if the velocity that is left is being rotated by the wall. Which sometimes happens to be towards the wall, but in other cases also away from the wall.
I don’t understand how this can happen. But it’s very clear to me that the velocity should never start pointing away from the wall. Remember that I can keep the down key pressed, but the entity starts moving upwards. This whole issue could point me to the bug. As the bug only seems to happen when the entity is not axis aligned. So that is my new goal for now. But I do realise a lot more has to happen before rotation can work correctly with the Separating Axis Theorem.