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.
2d collision with rotated pictures
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 5
- Joined: Mon Oct 26, 2020 12:08 am
- FloatingBanana
- Prole
- Posts: 22
- Joined: Sat Mar 02, 2019 4:57 pm
- Contact:
Re: 2d collision with rotated pictures
Take a look at the HC library.
Code: Select all
if anyMistake(self.english) then
print("Sorry, english is not my first language")
end
Re: 2d collision with rotated pictures
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.
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.
-
- Prole
- Posts: 15
- Joined: Mon Oct 26, 2020 2:02 pm
Re: 2d collision with rotated pictures
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
Additionally one rectangle could be entirely inside another.dezoitodemaio wrote: ↑Mon Oct 26, 2020 2:06 pm Since rectangles are made of lines you could check line to line collision
Re: 2d collision with rotated pictures
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.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.
-
- Prole
- Posts: 5
- Joined: Mon Oct 26, 2020 12:08 am
Re: 2d collision with rotated pictures
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
-
- Prole
- Posts: 5
- Joined: Mon Oct 26, 2020 12:08 am
Re: 2d collision with rotated pictures
i'll try to implement this alsodezoitodemaio wrote: ↑Mon Oct 26, 2020 2:06 pm 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.
-
- Prole
- Posts: 5
- Joined: Mon Oct 26, 2020 12:08 am
Re: 2d collision with rotated pictures
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
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 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.
- Attachments
-
- rotated_boxes.love
- intersection and collision of rotating boxes
- (3.76 KiB) Downloaded 263 times
Who is online
Users browsing this forum: Bing [Bot] and 1 guest