There is a really few amount of information and threads and I really wonder how I can be the only one having a hard time using networking behavior (command, rpc and stuff) with non player objects !!!
I’m not talking about objects spawned by the network manager here but really about objects already here in the scene.
In my case, I have a custom lobby scene, and I just can’t get my scene objects to send command/rpc, I always end up with some error like “no authorization” or stuff -_-
This is SO FRUSTRATING because I really feel like what I’m trying to do should be a Simple Thing !
Anyway, if any of you guys have an advice on how to manager scene objects, it would be greatly appreciated
This is not what is stated by the documentation (see the link I posted before) “Once scene objects have been spawned by NetworkServer.SpawnObjects() then they behave like every other spawned objects. Updates will be sent, and ClientRPC calls can be made.”
“All objects in the scene with a NetworkIdentity component will be disabled when the scene is loaded; on both the client and the server. Then, when the scene is fully loaded, NetworkServer.SpawnObjects() is called to activate these networked scene objects. This will be done automatically by the NetworkManager when the server scene finishes loading - or can be called directly by user code. This causes the networked scene objects to be spawned in a special way - the existing instances are hooked up to the network instead of new instances being created.”
This is SO UNCLEAR. My understanding is : objects already presents in scenes (and with network identity, obviously) will NOT be spawned like usual registered prefab but will be “activated by NetworkServer.SpawnObjects and then linked to network and be considered as spawned”.
So they’re in both scenes, active, authority allowed (checkbox checked) and granted (NetworkIdentity.AssignClientAuthority) but you can’t send network traffic from them?
I’m not sure that AssignClientAuthority is really on, that’s my buddy who’s working on it right now.
We sure looked messed with that function, I think I remember that we were not able to call AssignClientAuthority as there is no player prefab already spawn in that scene (it’s the lobby, where the game client is already connected but the “player object” doesn’t exist yet)
But does this player object must be there to assign client authority ?
But, is really assignclientauthority relative to the “player prefab” ? not the client ?
I mean, my client is connected, Do I really need to have the player object ?
If yes, that’s a bummer ^^
It sounds pretty ugly to spawn my player object, disable every behavior and rendering just to “have it” !
Authority means that you have the definitive/canonical/model copy of an object. Your changes are the “real” changes. By default, the server is the model for your game and has authority over all objects. If you want to control something and have your changes appear on other clients, you must have authority over it.
AssignClientAuthority is per object. Yes, you need a player object if you want to have control over anything on the server. Everything that you are trying to directly manipulate on your client is a player object.