How do I reduce lag for Layout with a lot of objects?

0 favourites
  • 9 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • Hi,

    I recently created a large island terrain generation system and have been adding systems that spawn trees, bushes, rocks, and different tiles randomly to make it all look more natural. While in debug mode, I can see that the game runs on 18 FPS which hasn't effected me running around the world just yet. I want to stay on top of this issue so that it won't get any worse as my game develops. Is there any tricks to reduce lag and improve performance for layouts with large amounts of objects?

    Tagged:

  • Is it 2d or 3d? If you can, replace the objects with a tilemap. You can customise the collision box for each object and it'll take up way less resources. Compress your images at somewhere like tinypng to save more resources. If your only running at 18FPS on PC then your going to have a hard time later down the line of you add a player, enemies with behaviours etc. If your aiming for mobile then it's only ever going to run on top end devices

  • Debug mode usually gives lower FPS than non-debug mode because the debug viewer itself is taking resources

    Construct can handle very large layouts as long as you do it correctly. It's hard to know why your game would slow down without seeing what you're doing tho. Can you post some screenshots of whatever you think is slowing the game down? Or a project file?

  • If it's only slow in debug mode I wouldn't worry, since it's most likely a chrome bug (that is currently worked on). If it happens without the debugger, you are probably checking to many objects for overlaps or similar every tick.

  • Also, what is the resolution of your images? Unnecessarily high resolution sprites can eat up your graphics memory. It could also be a fill rate issue, if you're layering too many sprites on top of each other.

    construct.net/en/make-games/manuals/construct-3/tips-and-guides/performance-tips

  • Here is what the project looks like when I preview it (This is using a lower layout scale so you can see the whole island)

    AS you can see, everything on the screenshot you see are individual objects around 15x15 pixels big.

    These are my events

    There aren't many collision checks and very few every ticks. I feel like it might be the amount of objects I have. The only reason I wouldn't go to tilemap for my tiles is because objects can help me give the affect that sand or water is lower (by a pixel) than normal land as you can see in this screen shot.

    The resolution of my images are very small as you can see, so I am not convinced it is the resolution of the sprites. Also, I do believe I have events that prevent any tiles from spawning on top of each other. I hope all of this helps. Thanks

  • Here are some things you can try

    - Change your Z elevation sorting code so that it only applies to WorldObjects on screen. You can do this by adding the “is on screen” condition

    - The above may result in flickering at the edges of the screen as objects sort as they come on screen. To solve this I like to make an invisible sprite, stretch it 2-3x larger than the screen, and then do an overlapping check with that object for sorting instead of “is on screen”

    - Try not doing an overlap check to destroy overlapping objects every tick. You only need that once, after all the objects are created, right?

    - Not sure how much this will impact, but you could try only doing greenery health checks after subtracting health from them

    - I would definitely try to figure out a way to do your terrain via tilemaps instead of separate objects. You can probably figure out a way to do the 1px lower effect with tilemaps

  • You should definitely be using tiles, for the floor at least. You can draw that outline in your tile as well.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for all of the suggestions, my game's FPS is already getting better!

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