How do I prevent a physics based game from being laggy

Get help using Construct 2

Post » Fri Dec 26, 2014 4:02 am

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?
Last edited by kossglobal on Fri Dec 26, 2014 6:25 pm, edited 1 time in total.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Fri Dec 26, 2014 8:58 am

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)
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
86
Posts: 5,482
Reputation: 59,750

Post » Fri Dec 26, 2014 1:50 pm

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 :)
Read this:
yeah, i really like to say that you should "Read this:"
B
13
S
6
Posts: 138
Reputation: 1,615

Post » Fri Dec 26, 2014 6:18 pm

zenox98 wrote: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.

EyeForcz wrote: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 :)


I have read all but I'll read everything again just in case. :)
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Sun Dec 28, 2014 12:55 am

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.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Sun Dec 28, 2014 4:31 am

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:

behavior-wip-chipmunk-physics_t110815

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.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Sun Dec 28, 2014 5:20 am

TiAm wrote: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:

behavior-wip-chipmunk-physics_t110815

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
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Sun Dec 28, 2014 9:43 pm

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?
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Sun Dec 28, 2014 10:00 pm

TiAm wrote: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.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests