How to interact with NetworkSpawnManager

Hello,

I’m trying to use this line of code to get a reference to a game object given its network object ID stored in a network variable.

GameObject spawnedObject = NetworkSpawnManager.SpawnedObjects[networkID.Value].gameObject;

but it doesn’t like that, saying "An object reference is required for the non-static field, method, or property ‘NetworkSpawnManager.SpawnedObjects’. I thought this meant I had to create an object of this class, but then it says “there is no constructor”. Can anyone push me in the right direction of how to correctly interact with this NetworkSpawnManager? Thank you.

I believe you should be using NetworkManager.Singleton.SpawnManagerinstead - however, I can’t check right now.

2 Likes

Worked perfectly, thank you so much. I’m so bad at finding the correct multiplayer documentation

1 Like

That’s hardly on you, the current documentation leaves a lot to be desired. Looking at the Boss Room code and threads on this forum can often be helpful though.

1 Like