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 / Mismatched physics on computer and cellphone

Author
Message
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 5th Nov 2018 21:24
I found this a bit more annoying than I expect.

I am programming on my laptop a small physics game, and testing it out on my computer and phone doesn't give the same results in terms of force, gravity, etc. Why is that?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 5th Nov 2018 23:48
Quote: "Mismatched physics on computer and cellphone "


I don't know what phone your using or perhaps what version android but ive never heard of this.

its hard to see the issue without anycode but maybe the problem is the screen dimensions are not matching the phone properly
as setting it to some dimensions there may be a border section on the left or the right of screen particularly noticeable with 3D
The problem is not calcualtions of the physics. It could also be that perhaps theres some code logic that could do with a little
improvement. Is it possible that you could post some code that people could see the issue your having, ven better if we can paste
into an example program and test for ourselves
fubar
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 6th Nov 2018 00:40
Could also be a different frame rate?
By default most phones are running at 30fps while your pc will likely sync to 60fps.

Ideally you want to ensure 60fps minimum for smooth physics as while physics is supposed to be handled at a fixed time, in reality it is not perfect and definitely produces unreliable results if the frame rate is lower than expected.
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 6th Nov 2018 10:15
This is happening to me when I am using CreatePhysicsForce()


same numbers, same example but different results on pc and cellphone.

On cellphone this force is stronger. I am using virtual resolution of 720p and frame rate is set to 60fps
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Nov 2018 11:25
If you are using 2D you should make sure to use SetPhysicsScale and keep it (and the size of your sprites) the same on all platforms. Also manually SetSyncRate to 60 and StepPhysics by 1.0/60.0 each loop.
Using AppGameKit V2 Tier 1
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 6th Nov 2018 11:35 Edited at: 6th Nov 2018 11:42
SetPhysicsScale is same on both devices. As well SetSyncRate , StepPhyisics, Gravity, etc.



Here is demonstration video of my problem (excuse my shaky movement):


https://1drv.ms/v/s!AtMv1SrHrjT38mzPq1V30pbj2IIC



However, if I replace CreatePhysicsForce with SetSpritePhysicsImpulse, that function is working accordingly on both devices.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 6th Nov 2018 12:36
I think smallg had the solution thinking more about it

Quote: "Your phone cant run the same frame rate as your pc"


Setting sync rate to a lower value may help
the default is SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
but you may have to set it much lower. I found I had to make all sorts of changes to get the frame
rates up on my very old and cheap phone with Pixelated Labrynth when it worked perfectly
well on other peoples phones
fubar
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Nov 2018 13:20
Are the sprite sizes the same?
Using AppGameKit V2 Tier 1
psychoanima
6
Years of Service
User Offline
Joined: 19th Jun 2018
Location:
Posted: 6th Nov 2018 13:35
Quote: "Setting sync rate to a lower value may help"


My blackberry phone has enough horse power to run simple simulations like this. Both pc and cellphone are showing constant 59 fps



Quote: "Are the sprite sizes the same?"


I didn't mess with the sprite size, they are imported without resizing, I made them all accordingly to my scene and target screen resolution( 720p)
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 6th Nov 2018 15:01
Possibly a virtual resolution or physics scale issue? i.e. the simulation is working fine on both devices, except one appears to have the physics zoomed in (does that make sense?). Difficult to say for sure without seeing any source-code. Can you make a simple demo highlighting the problem for us to take a loot at? I just had a quick play with CreatePhysicsForce and it looks like it is doing as expected on my PC and mobile.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Nov 2018 17:08
It could be the location you are setting the force is different for different resolutions. You should probably apply the force dead centre on the sprite using GetSpriteXByOffset and GetSpriteYByOffset otherwise it might not work as expected.
Like CJB said it would help if we had a basic example to test. Often I find the root cause of an issue when trying to reproduce the issue in a simple example.
Using AppGameKit V2 Tier 1
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 6th Nov 2018 19:28
You could also check the physics debug and see if they are reporting the same shape and positions on both devices.
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 6th Nov 2018 21:13
I've had this issue before, and the screen resolution thing sounds like it might be the reason. My phone is a much higher resolution than the window I run the game in from AppGameKit on the PC. I'll experiment with scaling the physics along with the resolution and see if that fixes the issue

Login to post a reply

Server time is: 2024-11-27 03:21:02
Your offset time is: 2024-11-27 03:21:02