Use of HLAPI in a non-multiplayer context...

Here is what I want to do. I want one “player” (call him/her the “controller”) to see the entire scene and have the authority to move objects. I want the other “players” (call them “spectators”) to be able to observe the scene, but not have the authority to interact with any objects (unless allowed by the controller). These players would only see the objects that have been flagged by the controller as “visible”.

I’ve been coding for Unity projects for a while, but always single-player. As this is a hobby project, I’d like to use the HLAPI to do it (for simplicity’s sake), but the HLAPI seems more focused on concurrent multiplayer (each client spawns a player, all players have the same authority, etc). Can I accomplish what I am seeking to do without major hassles in the HLAPI, or should I just bite the bullet and start with the Transport Layer APIs? Because this is a hobby project, I don’t need polish and speed; I’d like to get it running fast and dirty (which is why the HLAPI was attractive).

My thinking is that I can disable “AutoCreatePlayer” in the Networking Manager, give the host player the full authority, and hide all objects in the scene on all clients, then make them all visible again only for the host. But that seems too easy…

One other thing: The HLAPI is set up so that all clients can use (mostly) the same code. Is the use of different code prohibited/difficult using HLAPI? Can I create two different executables, one for the controller and one for the spectator?

“My thinking is that I can disable “AutoCreatePlayer” in the Networking Manager, give the host player the full authority, and hide all objects in the scene on all clients, then make them all visible again only for the host. But that seems too easy…”

Yes you can do this, and i think you should. (i do this for an asymetric gameplay and that work !).

“One other thing: The HLAPI is set up so that all clients can use (mostly) the same code. Is the use of different code prohibited/difficult using HLAPI? Can I create two different executables, one for the controller and one for the spectator?”

You can, but in the same project (i haven’t test with different projects).

You know, with the Transport Layer you can just say “Hello world”, and visitor will receive “Hello world” and display it.
It’s super easy to do this (less than 10 lines).

You can also test : if you are the server or not … You can create an application which can create room and an other which can only join a room …

If you use network behaviour, your two applications have to have the prefabs. That’s the only constrain. But if you use Transport Layer API, you can do what you want (really ! ).

1 Like