Problem with poling npcs with networkidentity

Hi, I wanted to know what is the correct way to pool spawned npcs on the server.
I am creating a number of npcs on the server and need it to sync across clients, so I instantiate them and then spawn that instance.
The problem comes when after spawning the instance I deactivate the npc (gameobject.SetActive (false)) object because if it is deactivated the object is not created in the clients.
So I thought of not disabling the objects but disabling all the object’s components and all the meshes.
Is there a better way to do this? Thanks in advance

You’ll want to check if Unet or Mirror, whichever you are using, is designed to handle NetworkBehaviour components getting disabled. I would expect them not to like that.

What I’ve done is write the scripts in a way so you can put them into a state where they don’t do anything by default. Put models and colliders on child objects, which you have disabled in the prefab. If using a rigidbody, configure it so it is effectively not doing anything. Then in one of your scripts, you have a method to activate the object on both the server and the clients, which turns on the appropriate models, colliders, etc.

You also need to handle a client connecting after the object has been activated, so just sending a single ClientRPC to activate on the clients isn’t good enough. You’ll need to send something specifically to the new client to tell it to turn everything on for just this 1 object.

I personally don’t think a networked object pool is really worth it though. I created one for cannonballs in my game as part of troubleshooting a low level unet issue I theorized was related to spawning large numbers of them in quick succession. I was wrong, but kept the object pool, even though it has been an occasional hassle to maintain. Though I did end up dropping Unet, which solved the actual problem.