How do i check which direction a charecter is in collision

so I am making a pvp game where two players try to knock each other off a shrinking platform an i want the players to be bonked in diffecnt direction of where they are in collision so if they are in collision from the right they will be pushed right so how can I tell which direction they are in collision from

Most simple way

PlayerA X position is lower than PlayerB X position
(Which would mean PlayerA is on the left from PlayerB which is right from PlayerA)

So you chekc if X of PlayerA is higher or lower than PlayerB
And now you add to it PlayerA is in collision with PlayerB

And you know you should knock PlayerA to the left

Now you repeat it for right and do vice-versa for PlayerB

For PlayerB it would be
PlayerA.X() < PlayerB.X() which means PlayerA is on left from PlayerB
PlayerA.X() > PlayerB.X() which means PlayerA is on right from PlayerB

Basically you can use same conditions for both but you need different actions for each