Search Unity

Sync run time objects in multiplayer game

Discussion in 'Multiplayer' started by pradeep_rangdhol, Mar 24, 2016.

  1. pradeep_rangdhol

    pradeep_rangdhol

    Joined:
    Oct 14, 2015
    Posts:
    7
    In a game, it is common practice to create run time objects which will be positioned & sized using Random values. How can we sync the transform of such objects in the scene of a multiplayer game?

    For example, Asteroids are the run time objects created in Flyer game of Unity VR Samples. If I convert Flyer game to a multiplayer game, is it possible to sync transform of all run time objects b/w both players?
     
  2. Freakyuno

    Freakyuno

    Joined:
    Jul 22, 2013
    Posts:
    138
    It's absolutely possible, and necessary. The system you're talking about when you say "runtime objects" is commonly referred to as a "procedural generation" of those objects. Because you're using a procedure (in code) to generate the object as opposed to using a designer.

    Basically, you have two components there. You need to create the object on the server and show it to all the players, and then you need to sync the objects position, rotation, damage (other attributes) when it changes to all players.

    If you're doing this inside unity instances it's not to hard, you should start with the unity tutorials at the top menu under "Learn" to see how to use Commands, SyncVars and Network objects.