NetworkServer.spawn Connection Handling

Can someone elaborate for me a bit more how the networkserver knows which client to give control of the object to?

In this image, the lecturer says that the “because this spawner belongs to me” at 9:16 in the video – but I don’t know who “me” is in this context.

Thank you for any insight, let me know if I need to clarify.

Hi there,

I think the logic is that the connectionToClient you are passing into the Spawn() method, is the connection to the client which owns the UnitSpawner. So since only one client has authority over that specific UnitSpawner, the connection to that client is passed into spawn here and assigned to the unit. Mirror knows which client has authority of that instance of the UnitSpawner.

To summarize, the UnitSpawner is a netowrkBehaviour with an assigned owner, which mirror knows about. The server has a connection to that owner called the connectionToClient. The server passes that connectionToClient into spawn and assigns it to the new unit.

Hope that helps, if it’s not clear, let me know and I will try to reiterate.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms