• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android Physics behave differently on different devices of the same platform(android)

B

booksmaster

Guest
Hi all! I'm building the turnbased mulpiplayer clicker game. It uses physics. The problem is that objects behave a little defferent on every client device. The difference is a very small but the problem that it is being accumulated with every turn resulting in compleately different look on every device in the end of game session. The world is sleeping between turns. The only params that are passed between devices are x and y where the user tapped(both integer). After every turn the game is waiting for every phys object to settle and sleep and then lets the other player to make his move. The manual says that physics are consistent between devices of the same platform but its not. Can anyone give any advice on that?
 
Last edited by a moderator:
I think the solution would be to have a host server that actually does the calculations and then just sending the position of things to the client. When GMS says that physics are consistent across devices, it doesn't really mean "If I send physics data from one device to another over the internet, the same outcome will occur"...It means "If I export to android and to PC, when I drop a ball in my android app, the same physics calculations will be performed as when I drop a ball on the PC version." There's also the issue of timing. You have to send the data between the devices when something happens, which means that the "things that are happening" occur at different points in time in each simulation, therefore introducing differences.

Hosting two separate physics simulations and expecting them to act -exactly- the same is a little bit optimistic, I think, physics is inherently kind of chaotic. Better to host one physics simulation and then just "show what happened on that simulation" to all the users.
 
B

booksmaster

Guest
I think the solution would be to have a host server that actually does the calculations and then just sending the position of things to the client. When GMS says that physics are consistent across devices, it doesn't really mean "If I send physics data from one device to another over the internet, the same outcome will occur"...It means "If I export to android and to PC, when I drop a ball in my android app, the same physics calculations will be performed as when I drop a ball on the PC version." There's also the issue of timing. You have to send the data between the devices when something happens, which means that the "things that are happening" occur at different points in time in each simulation, therefore introducing differences.

Hosting two separate physics simulations and expecting them to act -exactly- the same is a little bit optimistic, I think, physics is inherently kind of chaotic. Better to host one physics simulation and then just "show what happened on that simulation" to all the users.
The thing is the problem looks more like this "if I run the game on two different devices and will programmaticaly do the same thing at the same moment the outcome is different"
 
Hence why you remove the two devices from the processing and instead use a host to calculate it and then send that data to the clients.
 
B

booksmaster

Guest
Hence why you remove the two devices from the processing and instead use a host to calculate it and then send that data to the clients.
Coz sending x and y saves a lot of traffic ))

And sending 30 fps x 10-15 sec of data for every existsing object for every turn would consume 1000x more traffic and would probably take some time on slower internet like EDGE etc.

And I was hoping to use php+mysql server for simple matchmaking and data exchange. And what you suggest will require high power dedicated server(s)
 
Using two different physics systems that are meant to be in perfect sync is generally considered a bad idea no matter what you are trying to achieve. It's very probable that the same thing would happen if you ran two simulations on the same PC and sent data back and forth between them. That's just not really how physics systems play. I hope someone comes along and points out why I'm totally incorrect, for your sake, otherwise it might be time to start thinking of ways you can get the same result without running two simulations that are meant to act as one simulation.
 
B

booksmaster

Guest
I've made some small research and found that the sim is run in 2 different ways. I tested it on all phones in our office and found 2 groups of phones that behave the same inside group and the game is played perfectly inside any group. The problem is that I can't determine what the group of the phone depends on. I mean there are different cpus, screen, manufacturer etc inside same group.

Update. There are no two groups(there is but in different manner). In every group of devices the result are the same every odd try(So the physics sessions is consistent and work perfect every odd try). It doesnt really makes sense but still give some options for workarounds. For now I've made up a way to fix it. In the beginning of the game I make an invisible object and on the result of its falling on the ground I determine if this physics session is consistent and if not I restart the room.

Update. Ok guys physics are consistent unlike round and floor operations.
 
Last edited by a moderator:
Top