Checking from which side did the object collide

Hi there! Im making a 2D engine with collisions and the problem is, i need to know from which side did the object collide!
Here are some examples!

:black_large_square: :large_blue_circle:
We have a player, who is a circle, and a rectangle which is gonna be the building.
The game works the way that not the character moves, but the objects!

:black_large_square::arrow_right::large_blue_circle:
We are pressing the MOVE LEFT button and the objects of course move right

:black_large_square::large_blue_circle:
The object bumps into the player
And I want the objects to move back, as that’s how collision works! But I need to identify from which side did the square bump into the object, right, left, up or down? How do I do that?
PLease help.
Thanks

This is not a platformer, this is an open world game!

p. s. sorry if I didn’t explain properly, if I didn’t please tell me

6 Likes
// for left to right
if self x position > square x position {
  // it’s to the right
} else {
  // it’s to the left 
}
// it’d be the same for up and down
3 Likes

You know, I’ll try that again, but I remember that it didn’t quite rlly work (it kind of had the objects slide).
Also the player is the circle so probably you meant
if Self.X > Circle.X etc?

3 Likes

yes

you could use spy guy’s collision code (with credit) too

2 Likes

yeah, good idea, can you send it to me please? link or smith

2 Likes

it can be found in here

3 Likes

but yeah, is there like any other actual method except using other’s code? btw thanks!

2 Likes

there are, if the first thing I mentioned doesn’t work then I’d need to experiment more which I don’t have time to right now

3 Likes

should I tag like idk codehelp or pomtl or smith?

2 Likes

maybe codehelp

2 Likes

ok thanks a lot

1 Like

@CodeHelp please help

3 Likes

Hello? @ShevaKadu do you need help?

1 Like

Yes i do! Can u help me?

2 Likes

I wish I could help but i’ve never tried using collision code-I’ve never done a platformer heh

2 Likes

@Leaders can u please insert somewhere in the end of the topic near emojis “This is not a platformer, this is an open world game!”

3 Likes

Thanks a lot!

2 Likes

Hey sry got your message late but um…what do you need help with?

1 Like

Read the topic please :smiley:

1 Like

Ooo um…I would love to help but um…I’ve never ever done platforms sry maybe you could ask @Spy_Guy_96 maybe for help?