Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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


    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.     }