- Home /
How to tell when I've received the Server's state after the client connects
I'm trying to do a simple thing - I want to delay the Network.Instantiate() of my player object until my server finshes sending it's current state at time of connection. Is there an easy way for the client to tell when the Server has sent all of teh objects it has instantiated at the time of the connect. More details below
I have a spaceship game where players can visit different solar systems, each solar system is a separate scene, and each is hosted by a dedicated server / unity instance. The scene content is procedurally generated by the server.
When I start the scene docked, I could be exiting from one of a number of different space stations in the scene, I know which station because I save the station's gameObject.name at the time I dock.
When I undock, I simply do a GameObject.Find() for this GameObject by name, get it's transform and decide how far from it I should Network.Instantiate() my player.
Now . . . when I instantiate my player object, I do so inside a OnConnectedToServer() call, but at the time this is called, I haven't received all my server's procedurally generated content yet, so can't look up the space station in the scene by name.
I suspect I just need to go about this a different way, but would like to know for sure before I do a mid-cycle de-construct and re-construct on my code.
Any help very much appreciated.
Note I I know that the Server "State" is dynamic and will change as other clients connect, that's no treally relevant here because I know that the procedurally generated content is at least instantiated when the server starts.
Note II yes I know that Network.Instantiate will create client objects with Clone names (see here) - I've fixed that with a network rename object. (I'm happy to post it if people want it).
Note III Yes I know I can write my own Network.Instantiate() - I really want to avoid doing that.
Your answer
![](https://koobas.hobune.stream/wayback/20220613091714im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Having problems with Network.Instantiate 1 Answer
Network.Instantiate dont instantiate object 0 Answers
Network.Instantiate after loading level? 1 Answer
Network.Instantiate doesn't create player 2 gameobject. 0 Answers
Network rigidbody synchronize 0 Answers