Collision System used for 2D Platform Game with Moving Platforms.

Handle Side Collision
This function determines from which side the player collided with an object. It calculates how far the player has overlapped from each side (top, bottom, left, right). It picks the smallest overlap to decide the direction of collision.
Based on the result, it sets either the horizontal or vertical collision direction and stores the penetration distance in a list.
The overlap is calculated from all sides and the smallest of those values is chosen — the direction where the player is least inside the object. That’s the side where the collision happened.
This method is efficient but depends on a high framerate to avoid glitches. It’s not recommended for situations with lag spikes, but had great functionality in our 2D platform game.
The data from HandleSideCollision is then used to push the player out of the object. It picks the smallest overlap from each direction. A small offset is used to ensure the player doesn’t get stuck on the surface, helping avoid edge cases.
The player’s position is then adjusted in the opposite direction of the collision, ensuring smooth and consistent responses when interacting with the environment.