Collision Checks

Get help using Construct 2

Post » Sat Mar 29, 2014 2:56 pm

Is there a trick to reducing the number of collision checks that occur per second? I'm currently getting over 1600 in my current project and it seems to be affecting performance a bit. As I delete objects it gets smoother so I'm thinking I have to reduce the number of collision checks I am getting.

-Mike
Image
MIKE ASCHENBRENNER | RCMADIAX
Twitter/Instagram/Vine: @RCMADIAX
B
35
S
7
G
4
Posts: 186
Reputation: 4,574

Post » Sat Mar 29, 2014 4:01 pm

You could try "Every x seconds" as a top tier, and your collision event as a sub. Might even use a dt multiplier in the x for a variable timer.
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Sat Mar 29, 2014 6:13 pm

i find this a clear way to reduce per tick checks, system compare tickcount%2 = 0 (check every 2 ticks, will reduce collisionchecks by half !)

you can go higher, but you need to make sure your object collision still get registered (depends on speed and size of your objects)

i actually would advise everyone to do this, as a per tick collision check is way to much
ImageImage
B
70
S
21
G
7
Posts: 827
Reputation: 10,052

Post » Sun Mar 30, 2014 1:43 pm

It makes no sense to use dt in 'Every X seconds', it's already measuring in seconds!

The simple answer is to make fewer collision checks. Only collision check objects which really need it, and try to only check every few ticks if possible. Alternatively try to spread your objects out over a larger area and collision cells will reduce the collision checks for you.

BTW if that's 1600 a second, that's almost nothing to worry about at all. A single collision check is near-instant, and 30 a tick or so will have probably zero impact on performance (not counting poly checks).
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Sun Mar 30, 2014 4:53 pm

"Dt multiplier" as in 10 * dt
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 15 guests