Question by
Wittz8 · Jun 01 at 01:34 AM ·
networkingmirror
Trouble spawning objects on server in Mirror
I'm new to Mirror, and I'm having trouble getting some basic stuff working. I'm trying to write this GameObject
's Update()
method so that when the client connects, the object spawns in the server, and then deletes for the client. The GameObject
also has Network Identity
and Network Transform
components. This is my code:
void Update()
{
clientConnected = GameObject.Find("NetworkManager(Clone)").GetComponent<MyNetworkManager>().clientConnected; //checks whether the client is connected
if (clientConnected) {
NetworkServer.Spawn(gameObject, connectionToClient);
Destroy(gameObject);
}
}
While the GameObject
deletes correcty, it does not show up again for the clients. I'm not sure if the GameObject
is in fact Spawn()
ing correctly in the server but just isn't showing up for the clients, or if it's in fact not even Spawn()
ing correctly. What am I not understanding correctly?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613061228im_/https://answers.unity.com/themes/thub/images/avi.jpg)