I've been stuck trying to figure out how to program character collision in a 2D fighting game. Specifically for player movement, not for attacks.
I'm using Godot, and my current implementation is to check for an overlap of both characters' collision boxes, measure the distance of the overlap, then move both characters horizontally by half the distance.
This works fine; however, fighting games have corners, and players cannot go past the edge of the screen. So I have a check for whoever is in the corner, then make them not move, and make the opponent move the full distance.
I have a few issues I'm running into with this approach.
The players will visibly overlap for a frame before the function is called.
The collision function will not stop both players from overlapping without adding extra distance, which adds jitter, and you need more distance for high speeds. So I have to call the function every frame they're colliding, which doesn't seem like the correct implementation.
If the player in the corner is moving back and forth, the player outside of the corner doesn't have the distance applied 2x, which causes them to overlap.
