- Home /
Spawning twice upon joining server
Hello everyone,
Here's a short video showing the problem
Basically, I'm having this strange issue where the server is spawning an additional player upon joining. What's really weird is that the functions aren't being called twice, it's just spawning twice. This is apparent because there are no additional Debug.Log's are being displayed.
The code isn't that long, and it's really easy to follow. I commented the crap out of it. Since I don't like how Unity Answers shows code, here's the paste bin for it: PasteBin Code
I'm really hoping someone can point me in the right direction... Thanks in advance.
As far as the spawning code goes, it's just a simple network instantiate. I'm positive the error isn't there.
I looked through your code. There is no Initialization code in there. Also, there is no menu code as well to show us what your menu is doing.
The initialization code is there in startServer. You see no menu code because the buttons simply call these functions from elsewhere. The menu is based on NGUI, so there's a ton of classes there I can't post, but just know that the buttons you see in the video are calling their respective functions in that code.
That code only initializes the server... not instantiates the player/prefab.
The spawning code likely isn't to blame. Here are those functions though: http://pastebin.com/yj81TbvW. I'm connecting to the spawn manager and calling the SpawnEverything function, which in turn calls the appropriate spawning function.
The only way I can get this to work is by moving the SpawnEverything() call to the On$$anonymous$$asterServer.RegistrationSuceeded event. Weirdest thing ever. Every where else, including OnPlayerConnected, gives me this double spawn bullshit. And like I said, it's not calling the functions twice because none of the Debug.Log's are showing up twice (and no, collapse is NOT on in the debugger).