How to prevent corner slipping with a shortest axis collision solver

Currently I use AABB's to represent objects in my game engine, I resolve collisions between them by finding the shallowest axis, but this leads to a problem if an object is approaching another in a way that their corners would collide at a fast velocity, they will slip past each other and resolve on the wrong axis because one penetrated too deeply, for example:

We can see that the red square is approaching the green rectangle. They intersect and the solver sees that the smallest intersection is on the Y axis

Thus they sepparate on the Y axis, and the red square flies by the green rectangle, when it should have stopped on the left edge

I'm currently at a loss on how to solve this, any sugestions or fixes would be greatly appreciated!

• You might want to look into continuous collision detection (CCD). It prevents problems such as these. Plus other problems caused by discrete solutions. Dec 21, 2016 at 22:54

inters_vec = (xintersect,yintersect)