How do I optimize a project with a lot of objects.

0 favourites
  • 11 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I have about 40,000 copies of a sprite and it's slowing down my project immensely with CPU usage at 95%. With the debug menu I see that some event-sheets are also contributing to the lag but turning them off changes nothing, the same amount of CPU is used whatever I disable or modifie. So I'm having trouble finding what the problem could be other than the massive amount of objects.

    Thank you-

  • Why do you need so many objects?

  • Because those 40’000 objects are all tiles that make up the map. They change colour depending of the country owning them.

  • I definitely think the amount of objects is the issue. Are they tiles because you can own certain parts of the country (as opposed to owning the entire country)?

    If not, you could make each country an object (white), and change its color via the event sheet? That way you don't need a separate object for each color varation? You'd have 195 objects (which is still quite a lot imo), but it'd be a lot better than 40,000!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • They are all the same sprite (but copied over) and they already change colour and variable when owned by any country via the eventsheets.

    Here's how it look:

    *Its only a small part of the map

  • Static objects should not utilize CPU. (as long as they don't have any behaviors or effects)

    Make sure you are not updating them too often, avoid using "For each" for all 40K instances.

    Also consider using a tilemap instead.

  • They have line of sight behaviour but I dont think its checking every thicks unless I made a mistake. Also I don t think a tilemap would work because its 1 object. I need all the sprite or tiles of the map to old informations like variables.

    Also I am using a 3d camera that moves could it change anything about the sprites updating?

  • I have filled the layout with 57.000 instances of a small square sprite with no behavior. Then, when running the project, the CPU utilisation is 1% only.

  • I have tried too and the CPU usage go hight when the camera is moving (in my test the fps where still very good despite the CPU struggling for some reasons)

    Also in debug mod without deleting/diseabling anything, its says that the draw calls take up 25% of the CPU but when removing literally everything else but the sprites, the draw calls are now taking 95% and the CPU is still used too 100%. So I am not sure whats the issue.

  • 3d calculations for 40k objects will certainly heavily use CPU resources.

  • Also I don t think a tilemap would work because its 1 object. I need all the sprite or tiles of the map to old informations like variables.

    Use a Tilemap and an Array object to store per-tile data. That would likely be far, far more efficient.

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