How do I make better performance with collisions

0 favourites
  • 8 posts
From the Asset Store
Firebase: Analytics, Dynamic Links, Remote Config, Performance, Crashlytics on Android, iOS & Web Browser
  • Hello,

    I made a little match-3 game with a field of 8 * 8 objects.

    Everything is working fine in browsers on pc, but for smartphone / tablets the performance is very bad.

    Here some information of the debug of construct 2:

    -> over 250.000 Collision-checks / second

    -> 4.000 poly-checks / second

    -> 200 Moved cell / second

    -> 16 cell count

    -> 119 objects

    The other layouts like "game-settings / highscore / playerinfo ... " working fine, but in the game mode I have the over 250k collisions cause of the match 3 objects.

    Is there an alternative for the collision-checks? I saw something, that you can change the collision-checks, that they are every X seconds and not every tick, but I couldn't test it because I didn't find anything how to change this.

    Best regards.

  • The only answer is to do less collision checks. Have fewer objects, or only run collision checks on a timer if possible. Without any more information about your project that's just about all the advice that can be given.

  • Hi,

    I know that I have to reduce the collision checks, but I asked for how to make this? How can I make that the collision checks are not every tick but every X seconds?

    Or do I have to disable all collisions and than make this function with events?

    And the info to the project:

    On start of the Layout I spawn 5 different sprite objects (53 * 55 px) and this so often, that there are 64 (8 * 8) objects on the field.

    They have the "platform-behavior" and the "solid-behavior" so that they are falling down to the ground of the field automatically.

    Than you have to click on 1 object (with mouse or touch) where 1 or more of the same obeject are next to it. And if you do this, the objects get destroyed and for each destroyed object a new one spawns, so that there are always 64 objects (8 * 8) on field. (simple match-3 game)

    Best regards.

  • Hi !

    I might get this wrong, but why use physics at all If you have a match-3 puzzle-style game where everything is nicely grid-aligned, you can just manage the board state yourself (arrays, etc.) and write a simple "move" behaviour to get your blocks to fall down. Assuming the blocks have a predictable motion (e.g. all come from the top and fall perfectly vertically, etc.)

    This would much MUCH less expensive in terms of computations. You really want to keep physics only for situations that require it, e.g. when you don't control the environment, when you want projectiles or entities with realistic behaviours, vehicles, etc. For a board game, create your own representation of the board.

    'Hope that helps !

  • Hi,

    that would be perfect, but I didn't find like prepared objects / functions for this in construct 2, so I have to make all functions over the eventsheet... but I wanted to use C2 for easier game-making

    Any Tips which functions I can use or are there some prepared functions / obejects I can use in C2?

    Best regards.

    Edit:

    ah ok I think I got it what you mean:

    I deleated all behaviors of the match 3 objects, but collisions still enabled for touching / clicking them.

    Now the 250.000 Collision checks / second are gone and there are only like 2000 Collision-checks / second.

    And now I have add events that makes the match 3 objects falling down right?

    Than there is another question:

    How can I make an event to let the objects falling down + setting up the fall-speed of the objects?

    Or do I have to add a movement-behavior?

    Edit2:

    I made it now like this:

    The objects have the behavior "platform movement". Now there are only < 10.000 Collision checks / second.

    But now I have to add an event, that the object dont fall threw other objects.

    Any ideas how I can make this without the solid-behavior?

  • [quote:yhs8f2x2]I deleated all behaviors of the match 3 objects

    I have add events that makes the match 3 objects falling down

    That's pretty much it !

    Basically, for such a constrained layout, you don't want to rely on complex behaviours ; these are good for platformers, top-down shooters, physics objects where you need the collisions when you can't predict the outcome, etc. but here you'd fight the behaviours to make them do what they're not really good at.

    Also, you don't even need the collisions for clicking objects, you can just use "on mouse click" + "if mouse overlap" > action. Actually maybe a "draggable" behaviours would be better, depending on your game.

    Anyway, don't use any platform or physics or anything. You can for example have a representation of your grid/board in a 2D array, and run logic on the data in the array to detect when symbols are aligned, when there are holes and other blocks need to move, etc. Then the game you present to the user just becomes a visualisation of the data in the array.

    At first, don't bother with sliding symbols, etc. just do simple straight cell swaps on a timer (i.e. symbols instantly "teleport" to the next empty cell when moving down). When you've got that working, you can add some variables and basic math logic to make the symbols "slide"

    A Match-3 game can sound simple, but unfortunately with WYSIWYG tools like C2 the built-in behaviour don't help you that much. You can achieve a clean nice result but implementing basic logic yourself.

  • Thanks for help.

    I will try to make the fieldgrid with an array, thank you.

    Best regards.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • can checking distance (instead collision) improve performance?

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