How to replace (For each)?

0 favourites
  • 4 posts
From the Asset Store
This is a collection of 12 Combat Engines to insert, supplement, or replace conflict encounters for any game.
  • In this image, can I replace something from (for each) with something lighter? When there are more than 20 objects in the game using this configuration in the image below, the FPS drops a lot.

    When I removed the "for each" for testing, even with 200 objects my game continued at 60 fps

    (Remembering that the shooter also belongs to the shooter team)

  • It's tricky, I wouldn't have thought 20 objects would slow down with this For Each event.

    It does seem laid out as best as it can, as the "for each" needs to be there to individually check each Shooter against the family, which may be different for each shooter.

    Typically it's best to try and design game to be kinda "functional", meaning: Does your game really need to be checking alllll the time for all shooter objects to aquire a target? Or could this be lowered a lot more by including some conditions above the "for each" condition, such as "is onscreen" if you have a big layout with screen scrolling, or maybe designing a way to "disable" shooters that are too far away and therefore lighten the cpu usage of this for each loop.

    P.S. I see you post a few times asking for help so wanted to suggest: There's an unofficial Discord for Construct, with help section for both c2 and c3, tends to get a good mix of replies quite quickly and sometimes from many people giving their ideas and thoughts (depending on who recognises the issue and such!).

    discord.gg/construct-community-116497549237551109

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's not that you're using for each, it's that your doing it every tick.

    Try adding every 0.1 seconds.

  • Thanks for your help, The (ever 0.1) thing helped a bit,

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