How do I optimise many objects overlapping test

0 favourites
  • 4 posts
From the Asset Store
Soldier Test
$9.99 USD
A Construct version 2 & 3 "Stand-alone" RPG game with "In-Game Module" (IGM) integration.
  • Hey guys, I have an optimization issue I can't quite solve. Any help would be imensely appreciated, thanks. Here it goes:

    For this example's sake, my character will be called object TYPE A

    Image I have a layout with 200 objects TYPE B

    Now, around my character, there are always a few scattered objects of TYPE C that move with the character (TYPE A)

    For one purpose or another, I need to detect all the time a TYPE C object is overlapping a TYPE B object, and there are a hell lot of TYPE B objects, and that seems to be a very heavy thing to do with this many TYPE B objects. (NOTE: TYPE C objects are also ~ 20).

    So my question would be, how do I narrow down the TYPE B Is Overlapping TYPE C object check only to near the TYBE A object. There are a few sub-points that make this a tad more difficult.

    a) I need to perform checks all the time a TYBE B object is overlapping a TYPE C object as the TYPE C object has changing properties that then reflect on the TYBE B object, so I perform these checks every 0.5 sec. - This means I can't use On COllision as it is a one time thing.

    b)There will be more that one TYPE A object, despite me giving the example above as it being the player character, that was kinda misleading, cause there will be other TYPE objects with their seperate TYPE C objects (context is not an issues here, every TYPE C object knows to which TYPE A object it belongs, however the effect when overlapping with a TYPE B object is the same)

    c) I've tried picking TYPE B objects to by distance being under something from the TYPE A Object and to only check for overlapping with those but I either did it wrong or it had no effect on my FPS.

    Any clarity would be of much help, thanks.

  • OK. so I pick all TYBE B objects which are within some distance and set a value to 1, and then all that are further away from that are set to value 0 and then I pick the onces with value 1 for the collision checks and that seems to have a significant impact on the FPS for the better. Still, it's not perfect, if anyone has any other ideas they are still more than welcome.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The solution in your last post seems the most effective to me too (and you can modify the affected distance too),

    But I don't see why you would need to set a value?

    Why don't you just putthe collision check as a sub-event of the distance pick?

    This would eradicate the value setting and checking and maybe improving your performance somewhat.

    [EDIT]

    You could also set the distance checked for each TYPE C depending on their width/height.

    This means, you would set the checked distance to

    distance = "TYPEC.width > TYPEC.height ? TYPEC.width : TYPEC.height"[/code:2x64v92q]
    Like that, you would minimize the distance to the smallest value possible and decrease the amount of following overlapping tests too.
  • That's pretty cool, thanks! I'm playing around with these ideas right now, and things are looking better.

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