Reducing/Filterring Collisions for multiple instances

0 favourites
  • 13 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • 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!

  • 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).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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.

  • 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?!

  • 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.

  • 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

  • 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.

  • 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)

  • 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,

  • debug mode?

  • Centra hmmm not sure! I tried to optimize early on. Plus most of those objects are just background/scene art. So there's no thing to them except for holding their place on the map. Do your objects have a lot of complex code associated to them? I did what Colludium told me to do and disabled a lot of my enemies if they weren't on screen. This greatly reduced

  • if you're runing through a debug mode, try adding watch to only a few variables that are of your interest (like fps, cpuutil and so on..) and then change view in lower pane to watch. behold!

    p.s. you can always try your pc with debug mode from my game - https://dl.dropboxusercontent.com/u/136 ... index.html - go to options and turn on debug mode (you can also turn on / off particles to test the difference, it should work way faster without them <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> )

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