Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Multiplayer VR game with players in vehicle

Discussion in 'Connected Games' started by MythicalCity, Nov 12, 2019.

  1. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    396
    Hi, I'm making a VR project with a moving vehicle that has multiple players/passengers inside of it. So players don't have their own vehicles, they just share this one vehicle. What is the best way to sync the position of the vehicle with the players, considering that the players are children of the vehicle and we can't have any sudden movements or sudden changes in speed for VR players not to get sick. I'm using photon networking.

    I have tried syncing the position of the vehicle at the start of the level and also syncing it's speed (OnSerialize) however that doesn't seem to be accurate enough as the vehicle is slightly off it's position on each client. However this method is comfortable for users as the vehicle moves at a smooth and expected rate.

    When I tried syncing the position constantly, I found that the vehicle on the non-master clients was not smooth enough to make a comfortable experience, due to network traffic and lerping to the synced position it did not have a consistent speed. But of course the position was close enough to look the same on all clients.
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    7,289
    Using transform prediction, that probably what you need.
     
  3. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    396
    Thanks for the quick reply :) however I'm not sure what you mean. Could you elaborate? do you mean we should track the position of the vehicle over the network or just the players...?
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    7,289
    Clients should have calculated prediction path of vehicle / players in the future. So when receiving syncing position via network from the server, clients should be at that (or near enough) same position as server, at given sample time.

    If you not sure what I mean, look into FPS games, how similiar problem is resolved.
     
  5. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    396
    Thanks for the advice. Do you mean that I should sync the position of the vehicle then? or only sync it's start position and speed, while predicting where it should be?
     
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    7,289
    I mean, you should study and understand client prediction mechanics. Look for example DOTS networking solution on YouTube, there is technical prediction sample explained quite well. And of course look on relevant technique in general.

    Also, you can look at client prediction for multiplier racing games.
     
  7. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    396
    Thanks for the advice but unfortunately that doesn't answer my question about whether to sync the vehicle position or use another technique. I'll look into those examples to learn more about this but hopefully I can get some more direct advice on my question from another forum member.
     
  8. g_a_p

    g_a_p

    Joined:
    Mar 16, 2015
    Posts:
    191
    At the bottom of this page you will find the link to a document describing the development of a racing game made with SmartFoxServer: http://docs2x.smartfoxserver.com/ExamplesFlash/space-race

    The client is not Unity, but you should find interesting notions about the techniques used to handle realtime user interaction and synchronization (in particular starting from page 9).

    Om the subject of realtime synchronization you may also take a look at this Unity example: http://docs2x.smartfoxserver.com/ExamplesUnity/spacewar
    You will also find a link to a detailed tutorial.
     
unityunity