Problem Found?
Even though I was pretty frustrated at the start of the week due to the collision problem. I managed to keep going and come up with a different approach to tackle the problem. I decided to make the camera not move during gameplay. The reason for it was that I started to suspect the tile position not getting moved/changed, but the entity’s position did. With position being moved I mean relative to the camera/simulation region.

This gave me a better overview of what was happening. Now I could easily see that when the first overlap happened the position was already incorrect! So the frame before it the entity had moved too much. That’s exactly where the bug is.

Unfortunately I didn’t manage to come up with a working solution. I thought I had one, but it didn’t work or the implementation is bugged. So for the train ride home I can see what goes wrong there and hopefully fix this issue. At least it is exciting to finally see progress again.

After not getting the code to work I realized that what I was doing was probably way too far off of the final algorithm. So I threw the code away and started over. Trying to fully implement the separating axis theorem. Even though we would be doing unnecessary work, chopping that work down comes later. But in the end it didn’t change much. It’s still not working, but I do understand the original problem I had better.

We need to check if there is overlap. Once we know there is no overlap we can still move in a direction. If that direction is the correct one, then we can move as far as the gap allows us to. Otherwise we would overlap the next frame and we want to prevent that. In my new code that seems to work now. However only for one axis and only if you don’t move into the opposite direction after that… Since that part works I will stick to this code for now and see what the new problems are.

Last modified: October 20, 2022