Collision detection: Complex polygon or multiple blocks?

0 favourites
  • 8 posts
From the Asset Store
Detects any kind of ad blocker. Very easy implementation into already existing projects
  • 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

  • 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.)

  • 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...

  • I decided to conduct my own simple test:

    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.

  • 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.

  • 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...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)