Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Looking to treat a client as a spectator only

Discussion in 'FPS.Sample Game' started by timatchley, Dec 22, 2018.

  1. timatchley

    timatchley

    Joined:
    Apr 8, 2017
    Posts:
    2
    Hi there,

    Is there any straight forward way to connect a client instance and treat it as a spectator instead of being an actual player-client?

    I've noticed there is a SpecatorCam script but I'm not sure how its put in use with the existing code base.

    Thanks,

    Tim
     
  2. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    206
    Howdy Tim,

    You could disable gravity on that player character (or make a new character) and also disable guns ect. Turning one character into a spectator.

    Cheers
    Micah
     
  3. Aquastar

    Aquastar

    Joined:
    Jul 17, 2013
    Posts:
    29
    Change the code in GameModeSystemServer.cs from
    Code (csharp):
    1. if (charControl.characterType == 1000)
    2.     SpectatorCamSpawnRequest.Create(PostUpdateCommands, position, rotation, playerEntity);
    3. else
    4.     CharacterSpawnRequest.Create(PostUpdateCommands, charControl.characterType, position, rotation, playerEntity);
    to
    Code (csharp):
    1. SpectatorCamSpawnRequest.Create(PostUpdateCommands, position, rotation, playerEntity);/code]
     
  4. timatchley

    timatchley

    Joined:
    Apr 8, 2017
    Posts:
    2
    Hey Aquastar, thanks for pointing to this code. I think what I'm looking for is more or less to have not all clients, but just a single client connected to the server behave in this manner. So i think the original code looks more or less like what I need. I'll take a stab at seeing if I can write a hook to set a specific client to have charControl.characterType == 1000.

    That sound about right?

    Tim
     
  5. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi. I tried the tip above but i get only a crazy camera on latest github version.
    Are they any news for a spectator view?
     
  6. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    81
    We have made a normal character without weapons, 1p arms and UI overlays as our spectator.
    We have given him fast movements (But still using gravity for now).

    Since we have already added 2 more teams to the game (Unity default is 2) we added yet another team for spectators.
    So if you are a spectator you spawn at team0 and are not part of the general game rules and can move around freely.

    We haven't really used it for anything yet as people would rather play the game that spectate.
    But we plan on using him as a camera-man to record some game-play video soon.
     
    keeponshading likes this.
  7. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    That s brilliant. During working hours i could run around a car for review with spectator team. For Afterwork hours other teams could join and shoot it down.)

    Did you have some further tips for creating another charakter and an one additonal team.
    It s an great idea to extend the normal game mode this way.

    I just managed to fork FPSS and to create an empty level in an branch. (Thanks to Agressive Mastery.) and integrated Github for Unity.
    https://github.com/sasa42/FPSSample/tree/add_new_level?files=1

    Try to do small additive clean steps with documentation to give something back to this community and try to can easy merge new development from master.
    Think as soon as FPSS runs on HDRP package out of preview this is the most killer Unity Tutorial ever.

    ECS, new networking, HDRP, Shadergraph and Visual Effect Graph. I feel like learning Snowboarding on the big Halfpipe. But this worked out too, finally.)
     
    Last edited: Apr 2, 2019
  8. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    81
    If you look for all scripts with TeamA and TeamB in them you should be able to add more teams this way.
    Also remember to add them to the physics layer collision matrix.
     
    keeponshading and Stexe like this.
  9. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Thanks for the pointing.
    Is there a complete duplication of the Terraformer needed too. Or did you managed to hide the weapon on a “ runtime instance"…?
     
  10. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    81
    We added a new duplicated character as a spectator and removed all any wanted stuff on him.
     
  11. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    81
    Well calling it a duplication is a bit misleading as you cannot simply duplicate characters but have to create their asset files using the FPS Sample menus... There should be a post here somewhere explaining how to do that.