Jump to content
  • Advertisement
Sign in to follow this  
chaosmaker

Physics based multiplayer simulation game

This topic is 2122 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I asked the same question at Unity forums but I wanted to get the ideas of you guys also to have an idea out of Unity.

We are working on a multiplayer pool game heavily based on Unity physics (PhysX) and we managed it have a stable version of the single player gameplay.

For one week, we are working on the multiplayer version of it. Firstly I can say I am not a networking or physics expert but I know all the concepts of them, have 3 years background in game industry and have made a long research about it before I came to here.

Our current solution was the easy one which turnout to be not that easy. It is sending force direction and position from clients and calculating physics on both client/server and correcting the results (supposed to be too low) from the server at the end of the turn. To be able to make this work, we have made lots of investigation:

Firstly; simulation wasn't even same at the same computer with the same executable. To be able to correct it, we have to work on many Unity parameters, we corrected it up to same extent but none of them worked perfectly.

Our final results with break shot for 15 + 1 balls:
Client, two same shots, three balls position:

Ball_1: 7.647239, 1.791727, -7.450733
Ball_1: 7.647166, 1.791727, -7.450527

Ball_12: 3.079326, 1.791727, -3.05286
Ball_12: 3.080814, 1.791728, -3.052271

Ball_15: 7.133366, 1.791727, -11.65263
Ball_15: 7.133381, 1.791727, -11.6526

Server, two same shots, three balls position:

Ball_1: 7.649154, 1.791727, -7.458591
Ball_1: 7.649155, 1.791727, -7.458614

Ball_12: 3.076369, 1.791727, -3.062551
Ball_12: 3.076268, 1.791727, -3.063016

Ball_15: 7.1292, 1.791727, -11.64938
Ball_15: 7.129121, 1.791728, -11.64801

As you see the results are very close now but still even 0.01 differences make significant differences at some points (with a strong force or situation like in the client ball enters pocket but in the server it doesn't with a very small difference and such..).

I know the main problem here is physics random numbers and floating point arithmetic but I still believe there could be a workaround for this as it is a turn-based game at the end.

So my question here: Is it possible to make Unity physics deterministic and make it work with this approach?

Or:

Only way for this is state sync from server to clients which uses bandwidth around 6kB/s per player (16 balls, 12 bytes for position, 16 bytes for rotation, 10 bytes for header). Down side for this is; it will very expensive when we reach huge amount of players, also connection speed could effect this a lot.

Or:
Writing our own stable physics for it. Down side for this is; production cost and optimization issues. Possibly we could use another physics library with Unity but not sure if it will worth the results.

I hope someone could lead me to a possible solution for this.

Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement

I don't know myself, but I've heard a couple of people claim that deterministic physics isn't possible with Unity.

 

Deterministic physics is a very attractive way of making a multiplayer physics game send very little data. I'm doing this, but I have my own physics code, so when it breaks it's my own fault :P

Share this post


Link to post
Share on other sites

This may not be what you want for your game, but one approach you could take is to have the physics simulation take place only on the machine of the player whose turn it is, and simply transmit the positions of the balls to the other player. This solves your problem (I think) but it also makes scaling the solution easier. For example, if you decide at some point to have multiple observers of the game, transmitting the results is a straight-forward extension of transmitting the ball positions to the opponent. This comes down the idea that there is only ever one source of the Truth in the system and everyone is an observer (until it is their turn of course).

 

-Josh

 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!