- Home /
Why scene objects in multiplayer will not spawn, if enabled after scene is loaded?
Hello everybody, it took me time to understand my question, and here it is.
I have a scene of rooms with animated avatars. The first room is enabled when scene is loaded, while the others are disabled, but the avatars inside these rooms are set to be enabled (but the room is off, so they are "off" as well). Once I enable the next room, and thus disable the previous, the avatars automatically "active" and execute their script.
Now, in the network setting, avatars are scene objects. When scene is loaded they are loaded, but when the scene is loaded and they are in the "off" room, it seems they are actually not treated as those avatars who active in the first room, and then in NetworkIdentity, this button appears.
I assume that because they where "already" disabled when the scene was loading, they did not have the authority of the initially enabled avatars. So when enabled, they play only bool animations, but not triggered animations (as explained [here][2]).
Also, following the logic of on level load, this can be solved by breaking the scene into rooms scenes, but before, I want to understand this.
Answer by unidad2pete · Aug 17, 2017 at 10:08 PM
Objects with Network identity are scene objects and needs to be spawned on the scene by server. When you starts the server:
NetworkServer.SpawnObjects();
I dont know if that is your problem but try it. And, if the object network identity is set to server only, only will be spawned on server client, maybe you dont need check server only , only empty.
Thank you Thank you Thank you!!!
You've directed me to the right direction: I used actually NetworkServer.Spawn(gameObject);
in awake function, very simple and it works!!
....thanks again.
Answer by Eco-Editor · Aug 22, 2017 at 08:12 AM
GOING BACK to this question!
It's not working very well for me after looking at it again: I have, on the client double of each character. Not on the server, just the client! I have double of each character, and unity actually create a clone of each spawned avatar! At first you don't see the clone, but when the server is joining the same room, you suddenly have two of each avatar! This is no go for me. I need to have only one avatar of it's kind in the scene, regardless if the server is joining the room.