# How do I determined the side of a collision ?

0 favourites
• 4 posts
From the Asset Store
Build your own spaceship for your side scroller space shooter games with various components.
• How can i get collision sides of an object -

e.g. top / bottom , left / right with a rectangle ?

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Pin additionable hitboxes like these which is quite reliable with simple objects or use formulas to calculate relative posotion of projectile right before collision.

colX = object.X - projectile.X

colY = object.Y - projectile.Y

If colX > 0 & colY < 0 & colX > colY then it was hit from left

If colX > 0 & colY < 0 & colX < colY then it got the bottom and etc.

• Wow, i hoped there would be a simpler solution -

the mathematical one is probably the better one in Terms of Memory usage -

but the worse one in Terms of brain capabilities

! colX > colY ! this third condition i was missing ;

thanks a lot for the detailed answer !

• angle(x0,y0,x1,y1) gives you the angle between two objects

That can be use to determine a side.

For example if the return was 0 degrees you would know it was on the right side.

• 4 posts