Awesome thanks for the reply! Good to hear that both methods have good performance.
I am a bit worried now though of lets say the character being in the corner next to some walls, and all of a sudden they use a move that makes them have a bigger hitbox, how would you prevent them from getting stuck in the wall?
I could maybe prevent the move from being done next to the wall if it goes through the wall upon completion but I think that would be annoying for players. I might just have to keep the same hitbox all the time maybe.
I see two approaches to solve this, assuming that you are using two fixtures for the same body (each fixture for a different player stance, deactivating one of the fixtures' collisions when needed). Both approaches prevent the move
before making it, so you don't have to wait to complete the movement.
The first approach is the simplest one: Call an AABB raycast before making the move. If you have obstacles, then don't allow the move, nor activate the corresponding fixture. The drawback is that you are restricted to a rectangular shape for checking it
(the AABB), so if your fixture is not a rectangle, or if it is slightly rotated, you could have precision problems.
The second approach is better in terms of precision, but you will spend a timestep checking: When the player has to make the move, activate the fixture but set a flag telling it that you are in a "validation step" or something like that. In the following
timestep, if you have the fixture activated but with the "validation flag" activated, check all the collisions but avoid them to react (by disabling the contacts in the PreSolve method), this way you can check if the fixture is overlapping with another one,
but without having contact reactions (like being stuck). Then deactivate the "validation flag" and if you didn't find any contacts, activate the fixture.
I'm not sure if I explained it clear, hope I did :)