Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Sync a Video on Client machines

Discussion in 'Connected Games' started by shantanu01, Jun 14, 2018.

  1. shantanu01

    shantanu01

    Joined:
    Jan 15, 2018
    Posts:
    4
    Hello All,
    I have 4 players joining on a local lan network. My player camera is orthographic. Player controls are disabled. Each player is spawn at a fixed distance from each other. Say for example player 1 is spawned at (-10, 0,0), player 2 is spawned at (0,0,0), player 3 is spawned at (10,0,0), player 4 is spawned at (20,0,0).
    myproblem.png
    In front of each player I have a Quad to which a video player component is attached and a video clip is to be played.

    I tried syncVars/rpc functions running on the server and client as well, but I am not able to get the desired effect.The video starts only on the server or the client if I press the SPACEBAR as I have added a code to play the video or pause it.

    Well I press Spacebar the video should start playing and all clients must be updated with the current frame of the video its on.

    When all the players are joined I want to start playing this video in sync so that each player sees a part of the video on their monitor screen (orthographic camera).

    I completed this https://unity3d.com/learn/tutorials...3.2034224582.1528794218-1204989338.1526534996
    tutorial example to understand how Network Multiplayer works in unity.


    Any kind of help will be highly apriciated.

    Thanks,
    Shantanu
     
  2. BrunoPuccio

    BrunoPuccio

    Joined:
    Dec 13, 2017
    Posts:
    22
    did you try something like this?

    Code (CSharp):
    1.     void Update()
    2.     {
    3.         if (Input.GetKeyDown(KeyCode.Space))
    4.         {
    5.             if (isServer)
    6.                 RpcPlayVideo();
    7.             else
    8.                 CmdPlayVideo();
    9.         }
    10.     }
    11.  
    12.     [ClientRpc]
    13.     void RpcPlayVideo()//server calls this method
    14.     {
    15.         StartPlaying();
    16.     }
    17.  
    18.     [Command]
    19.     void CmdPlayVideo()//clients call this method
    20.     {
    21.         RpcPlayVideo();
    22.     }
    23.  
    24.     void StartPlaying()
    25.     {
    26.         //play or pause video locally
    27.     }