- Home /
Network.Instantiate spawns multiple objects
It spawns as many as there are players connected
For instance, solo: works fine, 2 players: when I spawn something, 2 appear (one with an offset bc thy aren't right on top of the other)
I am spawning them in using reference object transforms on the player prefab, so I can only assume it is spawning relative to the other player too?
Thanks, Joey
Answer by KMKxJOEY1 · Apr 04, 2013 at 01:22 AM
fixed, i had multiple players in the scene, for testing. Even though they were disabled for the builds, the scripts were still running.
Answer by sasuke908 · Mar 28, 2013 at 07:47 AM
you might want to check that the person who instantiate the object is a server (as there is only 1 server in every multiplayer game (generally) only the server should instantiate an object)
if(Network.isServer){
//code
}
to make sure only the server instantiates a network object. (or if you instantiate a lot you might want to create a static class to handle all instantiation so that it will work on both solo and multiplayer)
Well the game is multiplayer only, by solo I meant testing in the editor
So a network.instantiate should only be called if you are the server?
If I am a client, then I have to send an RPC to the server to instantiate something?
Ok ive gone and done that, now only the host can spawn things :( perhabs i am misunderstanding your suggestion.
As long u use Network.Instantiate, very object should have the networkview component so every connected player should be able to see it :)
I've gone and done that, no change :( also, i tried switching to a a normal instantiate just for testing, and it still spawned 2 objects, just only one client could see them
you could paste your code here :D and i will see what i can do