Search Unity

Client as Viewer/Spectator

Discussion in 'Multiplayer' started by Max_Grob, May 11, 2017.

  1. Max_Grob

    Max_Grob

    Joined:
    Jun 9, 2015
    Posts:
    2
    Hello guys,
    I have a problem and I dont know how to solve it. Maybe ist because am a rookie in programming.


    Here is the thing;

    I have one Scene an two cameras.
    Camera one is attached on a simple fps Controller.
    Camera two is simply staying in the sky. There is no possiblity to control that cam (so is the plan).

    So far so good.
    What I try to do is, that the FPSController cam is controlled by the host and every client, who joins the game should spawn in camera two. I just want Clients to watch.

    I tried things like isClient, isServer commands but my understanding for C# is not high enoug to know what im doing there.

    Can anybody tell me what code lines I need to do that?
    and where they should be attached to. I have no idea what can do.
    hope you guys can help me.



    Thanks!
     
  2. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    First choose who is the host. Maybe the first player that connects will be the host. So check if there is any players on the server. If not. FpsCamera.enabled = true; SkyCamera.enabled = false;
    And if there is other players online, Other way around. That's just an example to get you started.

    But too be honest. I think you need to understand how Unet Works before you start. What is a server? What is a client? How can you run code on server etc. Read the documentation and if there is something you don't understand I'm willing to help you.
     
  3. TheGameLearner

    TheGameLearner

    Joined:
    Feb 10, 2018
    Posts:
    20
    Hey, I have a similar Idea but I am trying to make the Server as a spectator for a game where the Client plays in VR. If you were able to make something happen even for 3d Game, can you share some helpful tips?
     
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    UNET has died since this post. It's going to be removed. You can check out my own networking library.
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If only the server will be using this spectator camera, there is no need for this camera to be part of the scene or exist on the clients. Nor should there be a need for it to be a networked GameObject. Just instantiate the spectator camera from a prefab if IsServer is true.

    But as @TwoTen said, Unet has been marked Obsolete. Unless your game is already close to completion you should be moving to an alternative network API.
     
    Last edited: Apr 11, 2019
    TwoTen likes this.