Reducing/Filterring Collisions for multiple instances

Discussion and feedback on Construct 2

Post » Sat Feb 13, 2016 8:03 pm

Im getting about 80-90% CPU usage, with 1,120 objects on my gaming PC with GTX970 and my ultrabook with integrated chip. I'm getting anywhere from 400k-800k collision checks. My level layout is pretty huge at 14000, 6000. And I have around 150-200 enemies throughout the layout, which it's obviously checking collisions against bullets and hitboxes for each one. It seems like all the strain is on my CPU and not my graphics card, which makes me feel like it's the collisions (since collisions are handled by the CPU correct?) I'm going through and trying to replace <On collision> with <is overlapping: Trigger once> because I heard there are performance gains, but I cant do if for all event cases.

In order to reduce collisions, I was thinking on making the collision check start with an <Enemy Is On Screen>. Would that effectively reduce it to only check collisions of who's on screen? There are 3 different enemy objects that use the same code (all the enemy code is coded to the family). I'd have tested this first, as I usually do instead of resorting to the forums, but this would require a massive code redo that I'd rather go for an answer first.

Thanks!
B
35
S
5
Posts: 411
Reputation: 3,406

Post » Sat Feb 13, 2016 9:13 pm

It sounds like you need to disable the enemies who are way off screen. That should drastically reduce your collision checking (providing they are moving and somehow checking for overlaps/collisions).
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
69
S
18
G
65
Posts: 2,195
Reputation: 41,465

Post » Sat Feb 13, 2016 9:32 pm

Colludium wrote:It sounds like you need to disable the enemies who are way off screen. That should drastically reduce your collision checking (providing they are moving and somehow checking for overlaps/collisions).


Yup, I was thinking on doing that by putting an event with each collision to only check collisions if that enemy is On Screen first, would that limit the collision checks to only what's on screen? How do you disable an enemy? If I disable the group code, that would disable it for all of my enemies.

Also, if there are no Object A on screen, but I have a collision check for OBject A and Object B, does it still check for that collision? OR does it only check collisions for pairs if both objects exist?
B
35
S
5
Posts: 411
Reputation: 3,406

Post » Sat Feb 13, 2016 9:46 pm

When I say disable enemies I mean disable their behaviors - so they don't move, shoot, path-find, platform, or whatever else you have them do. The engine uses collision cells so there's no need to turn off collisions for enemies with your player.
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
69
S
18
G
65
Posts: 2,195
Reputation: 41,465

Post » Sun Feb 14, 2016 8:56 pm

Colludium wrote:When I say disable enemies I mean disable their behaviors - so they don't move, shoot, path-find, platform, or whatever else you have them do. The engine uses collision cells so there's no need to turn off collisions for enemies with your player.


Created "IsActive" boolean for each enemy. When they first come on screen, it is active and then starts to run through their code. This reduced CPU usage by about 30-40%! But my FPS didnt' change on my slower ultrabook... how can that be?!
B
35
S
5
Posts: 411
Reputation: 3,406

Post » Sun Feb 14, 2016 9:51 pm

Have a look in the debugger Profile tab to see what's using up your computer time. If you have a lot of objects on screen then it could be the draw calls due to a weak GPU - that's a common cause of dropped frames.
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
69
S
18
G
65
Posts: 2,195
Reputation: 41,465

Post » Mon Feb 15, 2016 5:07 pm

@Colludium

Draw calls is ~ 3%-4% with 1,130 objects on screen. Doesn't seem like that is very much against draw calls, even though 1130 objects seems like a lot? (most of the objects have their collisions disabled.

Engine is 25-35%

My My "GameSheet" is my main, and my Level1LSheet is my level specific sheet. Level1Sheet is very expensive at 50%-60%, but even when I disable all events in it, it's still at a high % rate. I am including a few sheets in my Level1Layout, are those making it appear as though Level1LAyout sheet is taking their CPU% load? I don't think my draw calls or engine % is too crazy.

Thanks for the help on this already btw
B
35
S
5
Posts: 411
Reputation: 3,406

Post » Mon Feb 15, 2016 11:22 pm

No probs. The only other thing I can think of is that you might have a blacklisted gpu driver. Run debug and check if the renderer is canvas2d or webgl.... If the gpu is blacklisted (canvas2d) then that could be the cause of the poor framerate.
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
69
S
18
G
65
Posts: 2,195
Reputation: 41,465

Post » Tue Feb 16, 2016 9:11 pm

It says webgl, but it's an older onboard processor GPU. It's the intel HD4400 GPU that comes with the i5 4200U processor. It's an ultrabook processor, so i think it's probably my worst case scenerio machine (good to test on)
B
35
S
5
Posts: 411
Reputation: 3,406

Post » Mon Feb 29, 2016 1:57 pm

How are you getting away with 1000 some objects and a.i.?

My construct engine starts at around 30% and hits 80 with about 120 objects,
B
10
S
2
Posts: 76
Reputation: 987

Next

Return to Construct 2 General

Who is online

Users browsing this forum: tetuan and 7 guests