So if I have 2 of these:
What shape should I use for collision detection? I don't want a rectangle because it's way too restrictive...
Also,is there a tutorial on how to implement that shape?
Help with basic collision detection
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: Help with basic collision detection
You can use a simple rectangle.
If this isn't precise enough, you can define a more complex polygon.
A simple table with a set of ordered x,y pairs, so that the polygon would be counterclock-wise, and convex.
Later on, for convenience, you can wrap it as a class, and implements methods for generating new polygons, check for intersection, etc.
Well, problem is you will have to handle all by yourself collision with others shapes (like circles, rectangles, lines, points). That will require some maths, but nothing complicated.
There's a handy library that deals with that kind of stuff very well, actually. Look for HardonCollider.
If this isn't precise enough, you can define a more complex polygon.
A simple table with a set of ordered x,y pairs, so that the polygon would be counterclock-wise, and convex.
Code: Select all
Polygon = {
{x =..., y = ...},
{x =..., y = ...},
{x =..., y = ...},
...
}
Well, problem is you will have to handle all by yourself collision with others shapes (like circles, rectangles, lines, points). That will require some maths, but nothing complicated.
There's a handy library that deals with that kind of stuff very well, actually. Look for HardonCollider.
Who is online
Users browsing this forum: Ahrefs [Bot] and 7 guests