Spawning Objects
ObjectNet allows to spawn objects over network, when those objects are spawned all network peers will be notified to spawn the same object.
You can spawn objects automatically by using NetworkPrefabs automatic detection ( see Registering Prefab ), this detection is made on the host or server only, and once detected this spawned object will be sprayed for all network peers.
On the server of host client, this spawn can be execute using standard Unity methods.
GameObject.Instantiate(this.prefabToSpawn, this.positionToSpwan, Quaternion.identity);
When this object is spawned, server or host will detect it and send spawn event over the network to all connected players.
Nonetheless, if you need to spawn object on Passive network clients or even to spawn on the same way on all parts of your game you need to use an ObjectNet special method.
// Send event to spawn this prefab on server
NetworkGameObject.NetworkInstantiate(this.projectile, this.spawnPosition.position, rocketRotation);
You can also use this method on the server side, on this case, you have the option to get the spawned object as functions return.
// Send event to spawn this prefab on server
GameObject spawned = NetworkGameObject.NetworkInstantiate(this.projectile, this.spawnPosition.position, rocketRotation);
Note: If you spawn an object using unity standard spawn on the Passive instance of the game, those objects will no be spawned on the other network peers, The standard Unity spawn method only works if you execute it on the server or host player and only if the object was registered on NetworkPrefabs manager.