alvyxaz / barebones-masterserver

Master Server framework for Unity
476 stars 106 forks source link

Best way to run Spawner as spectator? #204

Closed lthornebarbarian closed 6 years ago

lthornebarbarian commented 6 years ago

Hey alvyxaz, thanks so much for putting this all together! Great framework and I'm really enjoying all the extras you have implemented like txt chat in the lobby. Nice touch. I also have voice chat working via Dissonance with your framework during gameplay.

Background: I have everything working properly for a multiplayer (FPS) paintball game (think Golden Eye on the Nintendo64 w/out the split screen of course). I have a fixed camera in the Game Scene and that camera is active in the Spawner window, making my spawner windows a spectator client as well. I also have a Camera on my playerprefab which becomes the Main camera in the Client when a new player joins the game. At this point I have the basics working and the ability to view the games being played in Spectator mode via the Spawner windows for each game running on the server, but I need to figure how to tell if the code is running as Spawner or Client so I can finish off adding a few more features for Spectator Mode.

Request: How can I determine if the Game scene is running as a Spawner on my server or being run as a local user as a Client? My end goal is to programmatically enable/disable various cameras in the Spawner version of the game scene, making it a Spectator Mode client that runs on the server.

Also, what's the best method to implement in your opinion? I was thinking of passing another command line arg to spawner starter in the MasterAndSpawner.unity (scene) on the Spawner GameObject, and then check for that variable in my client(s), but I'm not sure if that's the best way. Or perhaps you or someone else has a better suggestion for differentiating between the Game scene running in the Client vs the Spawner on the server.

Great framework!! I cannot thank you enough for developing this and thanks in advance for any info/help you can send my way. -lt

Edit: Oh, almost forgot - is there a built in Variable like isServer, isClient for isSpawner, or something similar (and simple) that I'm overlooking?

lthornebarbarian commented 6 years ago

Never mind.

isServer, isClient and isLocalPlayer all return proper values in the client and spawner (returns true for isServer in Spawner).

Thanks again for creating this awesome framework! -lt