Is there a better way to do this? [Physics & Performance]

0 favourites
  • 7 posts
From the Asset Store
Firebase: Analytics, Dynamic Links, Remote Config, Performance, Crashlytics on Android, iOS & Web Browser
  • Hello!

    I have some performance issues in my project and aftwer a graphic cleanse I wanted to start looking at the debug console for CPU usage.

    My game is "doll house" kind of game and I use physics in a very simple way, I want objects to fall down until they reach the floor.See an example:

    Subscribe to Construct videos now

    Physics are deactivated in my objects by default, and only activated when drag starts.

    In order to check the collisions I use overlap.

    This works perfectly, but seems to be very CPU consuming. It runs good on my PC, but in android devices can be laggy.

    I'm not sure if there's a better way to achieve the same result?

    Thank you for your time!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I believe that the physical behavior consumes a lot of memory, maybe if you use the platform behavior, it improves performance, but you have to regulate the speed of the drop

  • How many collision and poly checks per second your game does? You can check these values in the debug view.

    You can try disabling groups of events to see if the performance improves. It's possible that the problem is not with physics, but with lots of events running on every tick.

    I also suggest adding a parent condition "Body Physics is enabled" to the event which disabled Physics:

    Body Physics is enabled
    ... Body is overlapping floors
    ... Or Body is overlapping floor_tiled : Body Disable Physics
    

    This will reduce the number of collision checks.

    And do the same for other events in that group.

  • How many collision and poly checks per second your game does? You can check these values in the debug view.

    You can try disabling groups of events to see if the performance improves. It's possible that the problem is not with physics, but with lots of events running on every tick.

    I also suggest adding a parent condition "Body Physics is enabled" to the event which disabled Physics:

    > Body Physics is enabled
    ... Body is overlapping floors
    ... Or Body is overlapping floor_tiled : Body Disable Physics
    

    This will reduce the number of collision checks.

    And do the same for other events in that group.

    Thank you this worked like a charm! it's no longer on top of CPU consumption!!!

    Those are the collisions... Not sure if it's too high, I don't have a reference.

    Since the game is about drag and dropping objects/characters I have a lot of 'is overlapping' things. Not sure if there's a better way to do that.

  • I believe that the physical behavior consumes a lot of memory, maybe if you use the platform behavior, it improves performance, but you have to regulate the speed of the drop

    Hey! Thank you for this idea! I may try to prototype something with this to see if it could potentially work.

  • Those are the collisions... Not sure if it's too high, I don't have a reference.

    Is this before or after you made those changed to the events?

    ~200 collisions per tick is perfectly fine. Even 1000-2000 per tick should not be causing major lags on mobile. So if the game still runs poorly on mobile, then the issue is with something else.

    Make sure that Framerate Mode is set to "V-synced" in project properties.

  • > Those are the collisions... Not sure if it's too high, I don't have a reference.

    Is this before or after you made those changed to the events?

    ~200 collisions per tick is perfectly fine. Even 1000-2000 per tick should not be causing major lags on mobile. So if the game still runs poorly on mobile, then the issue is with something else.

    Make sure that Framerate Mode is set to "V-synced" in project properties.

    Thank you! I made a build with the change you suggested and it already feels better on device! This helped A LOT!

    It's V-syched.

    The scene is very big and has a lot of objects, so I do expect some lag on low end devices. Mine is not very good actually, but it runs well rn (redmi note 9s).

    Is checking CPU consumtion list a good practice to spot stuff that is taking a lot of usage? I'm trying to optimize the game, but I'm not sure what other thing I can check.

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