Search Unity

Sync a Video on Client machines

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

  1. shantanu01


    Jan 15, 2018
    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).
    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
    tutorial example to understand how Network Multiplayer works in unity.

    Any kind of help will be highly apriciated.

  2. BrunoPuccio


    Dec 13, 2017
    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.     }
    12.     [ClientRpc]
    13.     void RpcPlayVideo()//server calls this method
    14.     {
    15.         StartPlaying();
    16.     }
    18.     [Command]
    19.     void CmdPlayVideo()//clients call this method
    20.     {
    21.         RpcPlayVideo();
    22.     }
    24.     void StartPlaying()
    25.     {
    26.         //play or pause video locally
    27.     }