Search Unity

Third Party Spectate on other players during multiplayer using PUN 2 (Photon)

Discussion in 'Multiplayer' started by Ansink, Jan 28, 2023.

  1. Ansink

    Ansink

    Joined:
    Oct 7, 2021
    Posts:
    10
    So here is the question. I have a PvEvP game. To put it simply, 2 players are playing on their own devices in a sudden death mode, where the first one to lose all lives loses the game.

    I want players to see what the other player is doing in a small window on the top right.

    I am using PUN 2 for my networking. Can you please suggest what should be done to achieve that?

    Screenshot 2023-01-28 194411.png
     
    Last edited: Jan 28, 2023
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,990
    You mean there are two players, and the small window shows the other player's view or actions? This isn't exactly spectating, which refers to one or more clients who aren't playing, just watching (spectating) the match. Just saying. ;)

    In its simplest form you could simply attach a second camera to follow the other (remote) player and render that camera's output to the small window. This does not require writing any additional networking code since it uses the client's state, it just puts the focus of the second camera on the other player who may or may not be in the visible area of the local client's camera.
     
  3. Ansink

    Ansink

    Joined:
    Oct 7, 2021
    Posts:
    10
    How can I achieve that...Do I just attach a photon view to the second camera to send the information...Like how do I exactly send the camera information of the other player?

    I can send basic data but how to send a video over the network?
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,990
    You don‘t want to send (stream) a video, that would be overkill! Also in terms of bandwidth, players will not expect a game to consume as much network data as streaming video.

    Assuming you already have the two player‘s positions synchronized you just need another (local!) camera to follow the remote player.
     
  5. Ansink

    Ansink

    Joined:
    Oct 7, 2021
    Posts:
    10
    Ok, I'll try that way.
    Thanks