How do I make a physics based game run smoothly(mobile)

Get help using Construct 2

Post » Fri Jan 30, 2015 3:45 am

Alright, I'm really frustated. I'm working on a game based on physics for 2 months and I have slowdown issues since the beginning. The slowdown is more intensive at the beginning of the layout. Restarting lower the slowdown a bit but can and will increase again. I've read @Ashley 's tutorial (https://www.scirra.com/manual/134/performance-tips) and I've made some changes that improved my game a lot, regarding to memory usage and size. It didn't solved my problem though. I know that physics behavior is very cpu intensive. However, my game is really simple and never go more than 27 objects with physics at the same time, actually in the entire layout. So here are some informations that might help you to help me lol

Smarphone: Sony Xperia L.
Fps
Completly unstable, going from 20 to 50 all the time. Frequently around 30 and 40.
CPU utilization
Around 65~83%. Frequently around 75%
Object Count
Never go more than 160
Objects with physics
Rarely ever have more than 27
Colision checks
It's really low. Around 200(7 per tick) and 2000(38 per tick)
Pixel rounding = off
Sampling = Point
Window view: 1280x720
Fullscreen in browser: Scale outer
All images are in power-of-two (32x32, 64x64, 128x128 and 256x256)
3213123123123.jpg


Topics from @Ashley 's tutorial
Common causes of poor performance
These topics below isn't a problem.
-No hardware acceleration
-Changing Text objects every tick
-Inappropriate usage of the Tilemap object
More important Topics
Make sure WebGL is enabled
It's enabled
Place objects using the same blend modes or effects on the same layer
I'm doing it. However, It didn't had any effect since I'm using 3 or 4 objects with effects, and they are sporadic.
Avoid objects with large areas of transparency
All objects have 100% of opacity
Avoid large areas of overlap between objects
I've changed all my background images to achieve it. Now they are overlapping each other only enough to hide the end of the image.
If you have an opaque background, set Clear background to No in Project Properties
I've already set it to yes.
Too many objects using Physics
"You should design your games to use a few large Physics objects rather than many small Physics objects."
As I've said. I always have 27 physics objects or less. They are in different sizes and angles to follow up the curves.
Example:
fisica objetos111111111.jpg

Creating too many objects
Again. Can't be a problem. I'm using less than 160 objects in every layout.
Using too many effects
I'm using almost no effects. This isn't a factor here.
Using too many particles
Particles isn't a problem either. I'm using it in some of my levels just recently and I'm aware of the object count in this situation and yet it's very low.
Using Sprites instead of Tiled Backgrounds
I'm using Tiled background for almost everything. In order to not have a completly square look, I'm using masks.
See:
masks111111111111.jpg

Not placing all used objects in the layout
I don't think it's a problem. I have all objects that i'm using in all levels in one layout. On start of layout, I destroy them.
Using too many loops
Certainly not a problem.

----------
I'm sorry for this wall of text, but I'm working on this project for more than 2 months already and I have this f***ing slowdown haunting me forever. Seriously, I don't want to give up on my game (crying face \o/). I followed every single step of these tips and many others that I found. Nothing helps.
You do not have the required permissions to view the files attached to this post.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Fri Jan 30, 2015 8:39 am

Share your project that we can test it.

I also have a Sony Xperia (Z Ultra).
Image
B
16
S
7
Posts: 126
Reputation: 1,920

Post » Fri Jan 30, 2015 1:20 pm

Are you using asm.js physics?

Share a .capx so we can take a look.
Scirra Founder
B
398
S
236
G
88
Posts: 24,441
Reputation: 194,661

Post » Fri Jan 30, 2015 4:01 pm

kossglobal wrote:Objects with physics
Rarely ever have more than 27


27 physic objects on html5/js based engine is already too much, even half can slow game. Let's say, "few" physic objects is ok. Check scirra.com/construct2/games/mortar-melon game. I think this is limit of physic objects, that can be used for mobile games or good top desk computers. Of course, someone can say, it need better device, but game should run smoth on most devices and your Sony is maybe no speed deamon, but it is good example of average device and if game not runs on it good, it means engine is not enough fast for project. You can try with simpler collision boxes or smaller game scale, but over 20 objects will be always too much for mobile/html5/js.
B
10
S
1
Posts: 30
Reputation: 594

Post » Fri Jan 30, 2015 4:05 pm

Ashley wrote:Are you using asm.js physics?

Share a .capx so we can take a look.


I was using Box2D web. I switched and nothing changed. Is it possible to send the .capx for you by pm?No offense to anyone else, everyone here is incredibly helpful and cool, but it's internet and I'm in the final stage of the first version of the game, just need to change some things a bit and create more levels.

@Facet

I already tested it using only 6 objects and the slowdown persisted.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Fri Jan 30, 2015 4:52 pm

Facet wrote:27 physic objects on html5/js based engine is already too much

I don't think that advice is true any more with the asm.js physics engine. It should run close to native speed.

Make a minimal .capx that demonstrates the problem and share it here. If even 6 objects is slow, that suggests physics is not actually the problem, it must be something else.
Scirra Founder
B
398
S
236
G
88
Posts: 24,441
Reputation: 194,661

Post » Fri Jan 30, 2015 5:48 pm

Ashley wrote:
Facet wrote:27 physic objects on html5/js based engine is already too much

I don't think that advice is true any more with the asm.js physics engine. It should run close to native speed.

Make a minimal .capx that demonstrates the problem and share it here. If even 6 objects is slow, that suggests physics is not actually the problem, it must be something else.


Here is the .capx
https://www.dropbox.com/s/mvq6hbsoya2dn ... .capx?dl=0

Thanks for the help.

Edit: @Ashley , did you find something? :cry:
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Sat Jan 31, 2015 9:21 pm

@Ashley I hope you are right. I will test asm engine, I ignored physic in C2 because was not enough fast. Don't get me wrong please, I like C2 very, but it need (js/html5) good performance oriented project.
B
10
S
1
Posts: 30
Reputation: 594

Post » Tue Feb 03, 2015 4:22 am

@Ashley, did you see the .capx??

Also, with the new update, I can't preview it on chrome.
Error message:
Javascript error!
Uncaught TypeError: Cannot read property "isAmazonWebApp" of undefined
"My local IP"
Audio_Plugin.js, line 2197 (col 69)

Edit: I think some unexpected things may have happened on this update. See those Pets on the screenshots in my first post? They are too "heavy" now and I can't take them down like before and I didn't change a thing in the project on this weekend. So i'm pretty sure that is something about the update. It seems that they have a lot more mass or density.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Tue Feb 03, 2015 7:04 pm

@Ashley , Thanks for the bug fixes. Although, I think the density bug is still there. I have a projectile with a density of 4 and they act like it was 20 or more.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, dand, Google [Bot], tinhofiel and 28 guests