How do I prevent a physics based game from being laggy

0 favourites
  • 9 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • On my phone it's really laggy. Specially right after loading the layout. Sometimes It runs smoothly and sometimes the game has such a slowdown in the travelling object that makes It unreallistic and ugly. Looks like it's "decelerating" and "accelerating".

    The game is yet in beta stage. I only have 5 layouts. The memory use is around 167mb and the download size is 8mb and 230 events. I don't have any large image in my project as well. I also tested in two other phones and It lags too but less.

    Phones tested: Xperia L and Samsung Galaxy s4

    Could someone explain me why?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Need a lot more info.

    What version of C2 are you using?

    What export wrappers have you used?

    How are you testing - export or over wifi?

    Are you mixing the physics behavior with other behaviors ( such as platform, etc - not really designed to be used together)?

    What does debug say? (no. of collision per tick, etc)

  • i dont know if this would help but have you read some of these:

    https://www.scirra.com/tutorials/search ... erformance

    Maybe it will help you <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • Need a lot more info.

    What version of C2 are you using?

    What export wrappers have you used?

    How are you testing - export or over wifi?

    Are you mixing the physics behavior with other behaviors ( such as platform, etc - not really designed to be used together)?

    What does debug say? (no. of collision per tick, etc)

    What version of C2 are you using?

    • r192

    What export wrappers have you used?

    -I didn't export anything yet. I've tested with wifi

    Are you mixing the physics behavior with other behaviors ( such as platform, etc - not really designed to be used together)?

    -Physics and scroll to are the only behaviors they have. I do have platform behavior but not in the same object with physics.

    What does debug say? (no. of collision per tick, etc)

    • 556 Object count (But they are all almost the same object only repeated), 40~50fps, 20~25%CPU 38.8mb of images.

    -Collision checks per sec = Around 600~900 (15/tick)

    -Poly checks/sec = Around 130~240 (3/thick)

    -Cell Count = 20

    Edit: zenox98

    Can't do anything until solve this. I also have 88 object right now. I'm using tiled images to get rid of all those sprites. Didn't help much though.

    i dont know if this would help but have you read some of these:

    https://www.scirra.com/tutorials/search ... erformance

    Maybe it will help you <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    I have read all but I'll read everything again just in case. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • I've done so many changes to increase performance and still a pain in the ass to run smoothly. The game run with lots of lag spikes and slowdowns but sometimes, in a short period of time, run smoothly. I'm starting to think that a game based on physics behavior is not possible for mobiles.

    Alright here it is all the data about the game's performance running on my Xperia L. Also I've tested in a Samsung S3 as well and it's a little bit worse, which is weird because it has a better cpu.

    All tested using wifi and chrome browser.

    FPS: 30~55

    CPU: 45~80% (mostly around 70%)

    Object count: Around 85

    Image memory usage: Around 20mb

    Colision Checks/sec: 150~500 (mostly around 350)

    Poly checks/sec: 0~150

    ---

    Settings:

    Pixel rounding: off

    WebGL enable

    Sampling: Point

    Physics engine: Box2d web

    Construct 2 version r192

    Clear Background: No

    ---

    I'm using tiled images instead of sprites when it's possible. Actually, after doing this, my object count went from ~700 to less then 100 and still had a small effect on performance.

    I have less then 30 objects with physics behavior at the same time.

    Only one event is using 2 particle effects at the moment, which is the fire when I shoot. Their rate is 10 and 20 and last less then a second or two.

    PLEASE, if I forgot any information let me know. I really don't want to leave this project just because apparently it seems impracticable, which I don't believe.

    I appreciate a lot any help.

    Thank you.

  • Physics are pretty brutal on mobile, any way you slice it.

    I don't know how much code you've already done, but you might take a look at this amazing plugin by r0j0hound:

    To me, it seems to run smoother than box2d. It also has some amazing features that box2d doesn't, like collision groups (these objects only collide with each other).

    Also, spawning/destroying objects is hard on the engine if you handle too many in one tick, even if the action only happens occasionally.

  • Physics are pretty brutal on mobile, any way you slice it.

    I don't know how much code you've already done, but you might take a look at this amazing plugin by r0j0hound:

    To me, it seems to run smoother than box2d. It also has some amazing features that box2d doesn't, like collision groups (these objects only collide with each other).

    Also, spawning/destroying objects is hard on the engine if you handle too many in one tick, even if the action only happens occasionally.

    I've already done all the basics mechanics, so it would take a while. It worth all the work to change my entire project?(no disrespect to r0j0hound)

    Also I don't know if building my entire game using a beta plugin would be the best choice.

    What do you think?

    Anyway, the physics behavior's performance really let me down right now =/. I thought I was doing something terribly wrong.

    Edit: I've quickly made a new project with a lot more objects (with physics) and it ran smoothly. So I don't know anything anymore ... Don't know what to do

  • When you say you made a new project with more objects and it ran smoothly, are you talking about normal physics objects, or were you using r0j0hound's plugin?

  • When you say you made a new project with more objects and it ran smoothly, are you talking about normal physics objects, or were you using r0j0hound's plugin?

    About normal physics objects.

    After all changes it's running way better, I think I can stick with it. However, It's far from what we usually call a good performance . I don't know yet how to export so, in order to do a decisive test, I think first I'll backup my original project and test Chipmunk Physics by R0J0hound.

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