- Home /
Why does anything instantiated over the network by a client disappear when that client disconnects?
Hi there,
I'm trying to get my head round the new networking system in V5.1.1f1+ for a project I want to do and so i'm doing some smaller projects to be able to get some understanding before jumping right in the deep end.
Basically I was wondering why anything that is created in game by effect of a client disappears when that client disconnects?
For example I'm trying to make a simple instant messaging system which ive got working exactly how I wanted it to, the only issue is when the client that sent the messages disconnects, there messages disappear, the messages are displayed on screen by a UI prefab that is instantiated with all of the text of that prefab being setup when first spawned.
Is there some sort of setting somewhere to turn on spawned prefabs not disappearing on disconnect?
I'm really struggling to find good tutorials on the new networking solution,
Answer by meat5000 · Jul 12, 2015 at 11:52 AM
You need to have the client instruct the server to activate all objects and SyncVar the text.
If an object is owned by a client it exists on all machines but if the client disconnects, destroying all its own objects, this is what syncs to the server.
The basic tutorials are actually pretty good.
https://www.youtube.com/watch?v=NLnzlwCRjgc
The networking basics are the same for all operations. The difficulty comes in deciding what the server and client should do to minimise bandwidth but maximise experience.
Answer by seanr · Jul 15, 2015 at 01:44 PM
the IM messages themselves are spawned?
well, you could make the spawned objects create the actual IM messages in the UI instead of "being" them, then they would persist after disconnect.
or, you could implement custom spawn handling functions.
http://forum.unity3d.com/threads/controlling-the-spawn-behaviour-object-pooling.329902/#post-2140231
I realized what was occurring that the message ui were only spawning on the client and not on the host, I didn't have any sort of camera system set up so when a client joined there UI would just spawn on top of the hosts and display the messages which looked as if it was working however when that client disconnected there UI would despawn and remove all the messages because they were never being spawned into the host's UI :)
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
uNet Offline and Online Scenes the Same 2 Answers
How to send large messages through UNET 0 Answers
uNet Connection to IPv6 [Networking] 0 Answers
How to test single scenes with UNET? 1 Answer