Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. 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.     }