Collision polygons - more points or more shapes better?

Get help using Construct 3!

Post » Fri Oct 20, 2017 5:50 am

I'm making a pinball game and the playfield is an irregular shape (like pinball playfields generally are).

To use a single shape for the playfield it needs around 30 points to define the collision polygon (complete with warnings of reduced performance).

Is it better to use multiple shapes to create the playfield (each with say, 6 points) or to have all the points on a single shape?

Thanks :)

NB - can the warnings of too many points on a polygon be disabled? I kind of got it after the first extra point, but it repeats itself and each warning has to be dismissed.
B
14
S
2
Posts: 10
Reputation: 737

Post » Fri Oct 20, 2017 4:07 pm

This post seems a bit silly, you want to disable warnings as you add more and more points? The warnings are there for a reason, don't make it draw a collision polygon with 30 points or your game is going to run like crap. The object should really have fewer than 8 points. In a 2D game having a shape with collision so complex that it requires 30 points seems bizarre.
B
53
S
21
G
95
Posts: 2,450
Reputation: 56,115

Post » Sat Oct 21, 2017 5:33 am

Thanks for the reply @plinkie — much appreciated; so to answer my original question multiple shapes with more points collectively is preferable to a single large shape with more than the accepted number of points, as far as performance is concerned?

I'm fine with having a notification pop up when I add the first point past the accepted number, but one notification is enough — by that point I'm aware I've gone over so subsequent notifications are overkill, just a suggestion for UX.

The extra points are based on the curve of the shape and the ball (in this case) having to travel smoothly around it.

Thanks again :)
B
14
S
2
Posts: 10
Reputation: 737

Post » Sat Oct 21, 2017 8:27 am

Multiple objects. Preferably multiple instances of the same object, filtered by nearest or by range to reduce the aggregate collision checks per tick.
Mistakes were made.
B
62
S
30
G
134
Posts: 1,974
Reputation: 75,475

Post » Sat Oct 21, 2017 10:57 am

Yes multiple objects, no warnings here :D
B
53
S
21
G
95
Posts: 2,450
Reputation: 56,115

Post » Sat Oct 21, 2017 2:16 pm

Are you using physics? If you are then box2d has an 8 vertex limit, so the plugin divides up any objects with more than 8 vertices into different fixtures. An object could have many fixtures all sitting next to each other to make the overall shape you want. If you use more than one object then it's likely that you'll use more fixtures than if you had used one object instead (depends how the object's are divided up).

I'm making a physics plugin that will be able to help you with this. Check it out in the work in progress forum (Box2D+).
Learning other engines, but C2 still rocks. Image Image Image Image
B
81
S
22
G
96
Posts: 2,467
Reputation: 58,351

Post » Sat Oct 21, 2017 6:00 pm

Thanks for the responses and for clarifying the best approach.

The question stemmed from a Udemy course I watched where one object was given a *lot* of extra points:

Image

so on one hand I thought this could be applied to the playfield too, the warnings that popped up made me want a definitive answer from the experts (thanks!)

Box2D+ looks interesting — I'll definitely check it out :)
B
14
S
2
Posts: 10
Reputation: 737


Return to How do I...?

Who is online

Users browsing this forum: No registered users and 0 guests