does c2 test for collisions twice when using physics?

0 favourites
  • 5 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • -Answer-

    Construct does do this but only in specific cases.

    "...(disabling c2 collisions) will have no effect (on performance) if you don't test for collisions in events. If you make no collision tests yourself, then the C2 engine doesn't make any collision tests either, so it's irrelevant whether the object has collisions enabled or disabled.

    I don't think there's any way around having the two collision tests - not all games use a Physics engine, so C2 needs its own engine. But as I say if you don't use collision events on an object then it will only use the Box2D collision engine." -Ashley

    *** ORIGINAL POST ***

    Hey everybody,

    Does anyone know if construct 2 is using box2d internally for collision detection? Or is it using a custom system to test overlap.

    It seems efficient either way, but I wondered if it did implement its own algorithms, wouldn't it basically be doing double time when you are running physics on an object as well? Because you don't ask physics if something has collided... you have to ask construct 2 if something is overlapping...

    Just doing some exploring...

    ***END ORIGINAL POST***

  • I don't know how it works when you are using physics, but C2 definitely has it's own internal collision system that has nothing to do with Box2D.

    Basically, the way I understand it, the collision system takes the following 'top down' approach:

    1. Only compare an object against other objects in it's current collision cell(s).

    2. Start by doing a cheap boundary box test to see if the BB of ObjA is intersecting the BB of ObjB.

    3. If so, do a more expensive polygonal collision test, where the engine checks if the polygons of the two objects intersect anywhere.

    4. If physics are involved, I'm guessing that the poly test is handed off to the Box2D behavior, which tests for collisions using it's own internal algorithms. But...I could be wrong about that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • TiAm

    I just came up with a way to test. I created a bouncing ball project and disabled construct 2 collisions. Physics ran without a hitch. This means any object with physics is having multiple collision algorithms run on it...

    I need to set up some tests... I am curious what this collision testing overhead is.

    steps 1 and 2 are fast so I am sure it is nominal... but it may add for some interesting optimizations that could occur in a project. Box2d supplies collision information, but it is not exposed to c2. If you want to know if an object is hitting another you have to use c2 algorithm.

  • You can disable c2 collisions for a performance boost

    This will have no effect if you don't test for collisions in events. If you make no collision tests yourself, then the C2 engine doesn't make any collision tests either, so it's irrelevant whether the object has collisions enabled or disabled.

    I don't think there's any way around having the two collision tests - not all games use a Physics engine, so C2 needs its own engine. But as I say if you don't use collision events on an object then it will only use the Box2D collision engine.

  • Ashley - that's cool, real cool. So there really is no reason to go through a project and disable collisions on objects you don't need to collisions...? Nice... in that case... *editing OP*

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