Page 1 of 2
2d collision with rotated pictures
Posted: Mon Oct 26, 2020 12:13 am
by razerbladex43
Hi everyone,
i have a big question. my problem is that i want make a collision system beetwen two rotated/angled sprites. theses sprites are both same sizes and they have rectangle form. I need it for the tank game i'm actually making and it's very urgent so i need your help.
thanks in advance.
Re: 2d collision with rotated pictures
Posted: Mon Oct 26, 2020 2:30 am
by FloatingBanana
Take a look at the
HC library.
Re: 2d collision with rotated pictures
Posted: Mon Oct 26, 2020 6:51 am
by ivan
Rotated rectangles are not simple and it's even harder if you want to have some sort of decent collision response.
I recommend using love.physics or avoid rotation altogether.
For example, you can use circles or just rotate the sprite without rotating the collision mask.
Re: 2d collision with rotated pictures
Posted: Mon Oct 26, 2020 2:06 pm
by dezoitodemaio
Since rectangles are made of lines you could check line to line collision, something like
https://github.com/processing/processin ... -Detection. If any line of Rectangle A intersects any line of Rectangle B then there are colliding.
Re: 2d collision with rotated pictures
Posted: Mon Oct 26, 2020 8:12 pm
by ivan
dezoitodemaio wrote: ↑Mon Oct 26, 2020 2:06 pm
Since rectangles are made of lines you could check line to line collision
Additionally one rectangle could be entirely inside another.
Re: 2d collision with rotated pictures
Posted: Tue Oct 27, 2020 1:44 am
by nikneym
razerbladex43 wrote: ↑Mon Oct 26, 2020 12:13 am
Hi everyone,
i have a big question. my problem is that i want make a collision system beetwen two rotated/angled sprites. theses sprites are both same sizes and they have rectangle form. I need it for the tank game i'm actually making and it's very urgent so i need your help.
thanks in advance.
SAT collision detection may solve your problem. There is a tutorial of
SAT implementation made by recursor but this might mean you have to change your collision detection script completely.
Re: 2d collision with rotated pictures
Posted: Tue Oct 27, 2020 11:18 pm
by razerbladex43
I'm actualling trying to understand the separating axis theorem but it seems to difficult. also i know hc but i prefer sat i think i'll try to understand. do you know a french tutorial for the sat because i'm not familiar with english language
Re: 2d collision with rotated pictures
Posted: Tue Oct 27, 2020 11:20 pm
by razerbladex43
i'll try to implement this also
Re: 2d collision with rotated pictures
Posted: Tue Oct 27, 2020 11:23 pm
by razerbladex43
the game i'm making is very similar to this one
https://awesometanks2.com/ and if you can give it a look and tell me what kind of collision system they are using that would be very nice
Re: 2d collision with rotated pictures
Posted: Wed Oct 28, 2020 7:55 am
by siberian
May be will be usefull.
The main idea is to get the sum of the 2 shapes (hull). If the center of an object is inside a hull, the objects are intersecting.
In motion, check the intersection of the hull with a segment from the center of the moved object to its destination point.
The attachment rotated_boxes.love is no longer available