Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Unexpected differences in performance with simple physics game on mobile and pc...

Author
Message
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 29th Sep 2017 18:05
Ok, so I've been messing around with the Box2d commands and was surprised to see that the program performed significantly differently on the PC to on Android.

It wasn't as noticeable before I used the SetPhysicsGravity() command, but since using it, it's made a real difference in gameplay between the two platforms.

On the PC the physics object (A ball) floats down from the top of the screen, and when a force is applied to it, it whooshes off the top of the screen; very much like one of those beach balls when you kick it too hard; Where as on the Android it behaves more or less as I intend. The ball falls faster (as though it was heavier?) and it doesn't bounce any where near as high.

Has anyone else noticed this issue? Does anyone have any advice or help as to how I can make it more consistant across platforms?

Thanks in advance...

=PRoF=

janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 29th Sep 2017 18:26
This sounds like a performance problem.
Does the frame rate drop or is it any different from each other i.e. do you cap the frame rate to 30 or 60 frames.
Do you take frame time into account when applying forces ?
Maybe try to change the overall physics world size -> SetPhysicsScale( scale )
jhanson
6
Years of Service
User Offline
Joined: 19th Jun 2017
Location: USA
Posted: 29th Sep 2017 18:28
I haven't used those platforms in particular, but I noticed that the physics commands definitely feel different between the OS X and HTML5 platforms. For instance, in the platformer I made, friction seems much lower in HTML5 than OS X, so the character moves faster and slides further. I ended up coding it with increased friction that I turn on when building for HTML5. I set a constant at the top of the code that I change when I'm building for the different platforms (1 = html5, 2 = os x, etc.), and I look for that constant to decide which friction value to apply.
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 29th Sep 2017 18:42 Edited at: 29th Sep 2017 18:42
@Janbo:
Quote: "Does the frame rate drop or is it any different from each other i.e. do you cap the frame rate to 30 or 60 frames."

The game is capped at 30 fps using the SetSyncRate(30,1) command, and it runs at a constant 30fps +/- 1 fps

Quote: "Do you take frame time into account when applying forces ?"

Not sure exactly what you mean by this? I recently added StepPhysics(0.033) command before Sync(), but again, that has made no difference

Quote: "Maybe try to change the overall physics world size -> SetPhysicsScale( scale )"

I have that command as part of the physics setup. It's set to 0.05

@jhanson:
I may have to do that, but I'd rather not Good suggestion though.
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 29th Sep 2017 20:31 Edited at: 29th Sep 2017 20:38
Hm... SetSyncRate(30,1) and StepPhysics(0.033) sound fine
Quote: "I have that command as part of the physics setup. It's set to 0.05"

So if the virtual resolution is 100*100 the scene size is 5 meters ? and you have dynamic objects between 0.1 and 10 meters ??
Not sure if that helps your problem ^^
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 29th Sep 2017 23:49 Edited at: 29th Sep 2017 23:49
@Janbo:
Yeah, That sounds about right. Here's a screen grab to help you visualise it. There's only 1 dynamic object.

It's just the bit where it works ok on the PC or Android, but not both without me having to tweak the code. It's a little frustrating
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Sep 2017 09:45
do you use a sprite below at bottom, i remember the default border just stop objects and do not bounce.
try also SetPhysicsDebugOn ()
GetVirtualHeight () should fit to the physicscale as janbo mentioned.
possibly show a example code to play with.


AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.7.2) Radeon R7 265 : Mac mini OS Sierra (10.12.2)

Login to post a reply

Server time is: 2024-04-25 01:41:17
Your offset time is: 2024-04-25 01:41:17