[SOLVED] Performance / Optimisation help on a mechanic which involves spawning a lot of objects.

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hey, I am currently working on a project and I have a mechanic which requires me to spawn a lot of object at once (360 to be exact).

    It's becoming quite expensive because the player isn't the only character in the game which uses the same mechanic and I am using effects (all on one layer), so it soon adds up. Can anybody think of a less performance heavy method of achieving this mechanic, would writing this in JavaScript make much of a difference? Any help is appreciated.

    I have recreated the mechanic and it's setup in a blank project, so you can see for yourselves, but here is a screen shot of the logic as well.

    drive.google.com/file/d/1ISdG2I1jzLcoEV2cIM3mHRQy3ZwW7ZG2/view

    Subscribe to Construct videos now
  • Have you tried pooling this objects and use them from the pool?

    On start of layout create an amount of objects outside the layout and use them instead of spawn them. And when possible, reuse it, set it to invisible or move it outside of the layout and keep using them instead of spawn it.

  • It might be worth giving a try, though having 360 objects for each character always being alive will probably start stacking up as well. Thanks for the reply.

  • A quick profile shows the biggest performance impact is that it's absolutely hammering collision detection. Turning off bullet stepping and "bounce off solids" and relying on a single "is overlapping" event is far faster, at the expense of slightly reduced precision at the point of impact.

    The bullets have to test collisions constantly as they move, though. Probably a much faster approach would be to use raycasting to immediately identify all the points of contact with the scenery upon creation, and then just tween the bullets towards the destination with no collisions enabled.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Awesome! I totally didn't think of that, I'll give your Tween solution a try. Always appreciate the help Ashley!

  • I ended up going with your raycast approach, but used the MoveTo instead of Tween behaviour to move the "bullets". It worked a treat, thank you for the help.

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