Collision detection: Complex polygon or multiple blocks?

Discussion and feedback on Construct 2

Post » Sun Dec 21, 2014 7:41 pm

Hey gang, I'm working on a racing game, for my track collision would I better off creating a complex collision polygon or using multiple rectangular collision blocks?

Cheers
B
64
S
25
G
10
Posts: 654
Reputation: 10,842

Post » Sun Dec 21, 2014 8:27 pm

for the track, I would say rectangulars blocks would be better, not only can you adjust them, but they might also be easier on the CPU. (due to the fact C2 handles easily collisions checks while polychecks needs more time? which for a big precise track'may be too much.)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
22
G
18
Posts: 2,123
Reputation: 17,150

Post » Sun Dec 21, 2014 8:32 pm

@Aurel might have some insight. I doubt 'complex' polys would make much difference, as long as they were < 8 points. Having more objects (building with many boxes) would probably be a bigger hit on performance. But hey, I could be wrong...
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Sun Dec 21, 2014 9:17 pm

I decided to conduct my own simple test:

Image

The results are somewhat inconclusive...

For now I'm sticking with the complex polygon, which runs the same in a naked eye test, as the collision is more precise.
Last edited by Elliott on Sun Dec 21, 2014 9:24 pm, edited 1 time in total.
B
64
S
25
G
10
Posts: 654
Reputation: 10,842

Post » Sun Dec 21, 2014 9:23 pm

When creatad, road blocks auto-generate simple collision shapes on each sides (mostly bars, a few polygon shapes for turns) in Penelope.
As I'm not a C2 veteran, I wouldn't advise anything but to make LARGE collision objects because collisions are easily missed if your game is fast and if too much frameskip happens.
Image | @AurelRegard on twitter
B
19
S
6
G
1
Posts: 307
Reputation: 2,500

Post » Sun Dec 21, 2014 11:02 pm

@Elliott

Wow, was not expecting that. I've never seen a poly that complex. It looks like it's comparable to the 'many box' approach though, so I'd stick with it, given that it's less objects + easier to understand and tweak.

@Aurel

I think you're under-estimating yourself there... :)
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Mon Dec 22, 2014 2:16 pm

@TiAm

I have literally no idea how or why the multiple collision block version runs 3 frames per second faster, as the complex poly uses 3 times less objects, less CPU, less image memory, performs 4 times less collision checks per tick and roughly the same number of poly checks. Obviously the tests were not identical, and it was fairly sloppy, but I'd be interested to know if there's a simple reason @Ashley ?


@Aurel
Agreed on the large objects point - based on your similar advice from a previous thread I designed the game with this in mind from the ground up; I don't detect when the player has hit a barrier, I detect when they're not on the road.

And if you're not a C2 Veteran - heaven help the rest of us!

Merry Christmas guys.
B
64
S
25
G
10
Posts: 654
Reputation: 10,842

Post » Mon Dec 22, 2014 3:57 pm

@Elliott well, first the debugger adds quite an overhead (go into other debugger tabs to see if they cap up to you refresh rate) so the difference may not be huge.

also, a poly check is not a fixed calcul like a simple collision check, two poly checks may take a very different time to accomplish, since you did a road full of collisions testing polygons, you have one polycheck per tick (as the player is overllaping the road) that is easier to compute than the polycheck of the complex polygon.

however, it may be that in both cases, you computer is just fast enough to run correctly both cases.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
22
G
18
Posts: 2,123
Reputation: 17,150


Return to Construct 2 General

Who is online

Users browsing this forum: DuckoIII and 1 guest