- Home /
Network Instantiate error even when connected?
So I've been fighting with this simple script I've made which is supposed to fire a small projectile when the fire button is hit. Problem is, it doesn't instantiate and instead throws an error:
"Failed Network.Instantiate because we are not connected."
Thing is, I'm running a server and client side by side on my screen and they are connected. I can tell because both characters are plainly visible and respond to their individual inputs.
Here's a snippet from my code, the part that I suspect may be the issue...
if(isLocalPlayer){
if(Input.GetButtonDown(FireButton)){
Network.Instantiate(Ammo, GunSpot.position,GunSpot.rotation,0);
}
}
I'm new to the whole uNET, so any advice would be greatly appreciated.
Answer by Bunny83 · Oct 06, 2015 at 01:53 AM
"Network.Instantiate" belongs to the old networking system. Didn't you get some obsolete warnings?
If you're new to the new networking system i suggest start reading from here. The most important parts for your issue is most likely covered in Object Spawning and maybe Scene Objects. However i suggest to read though everything (maybe a couple of times).
Thanks! I didn't get any obsolete warning at all, but this makes sense now. I was running a little low on sleep and wasn't thinking straight I suppose. Thanks for the help and friendly advice!
Doesn't look obsolete here:
http://docs.unity3d.com/ScriptReference/Network.Instantiate.html
I'm with svendkiloo here. The old and new systems both still work, but it is SO ANNOYING when it doesn't say anywhere in the documentation which classes/methods belong to which system.
Unity's documentation is already horrible enough without having to deal with multiple networking systems with no clear delineation.