How do I make better performance with collisions

Get help using Construct 2

Post » Thu Jan 08, 2015 2:47 pm

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.
B
5
S
1
Posts: 21
Reputation: 419

Post » Thu Jan 08, 2015 3:34 pm

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.
Scirra Founder
B
399
S
236
G
89
Posts: 24,542
Reputation: 195,428

Post » Thu Jan 08, 2015 4:36 pm

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.
B
5
S
1
Posts: 21
Reputation: 419

Post » Thu Jan 08, 2015 6:21 pm

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 !
Image
Game Producer & Independent Developer - http://raphaelgervaise.com
B
24
S
9
Posts: 237
Reputation: 2,232

Post » Thu Jan 08, 2015 8:07 pm

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?
B
5
S
1
Posts: 21
Reputation: 419

Post » Fri Jan 09, 2015 6:41 pm

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.
Image
Game Producer & Independent Developer - http://raphaelgervaise.com
B
24
S
9
Posts: 237
Reputation: 2,232

Post » Sat Jan 10, 2015 11:12 pm

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

Best regards.
B
5
S
1
Posts: 21
Reputation: 419

Post » Sun Jan 11, 2015 7:10 am

can checking distance (instead collision) improve performance?
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
64
S
14
G
2
Posts: 292
Reputation: 6,678


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests