- Home /
Network - Load For Late Players
Hello,
My first ever networked game is coming along quite nicely. But I've just found a really big problem when a player/client joins late (so during a game).
Example, lets say I set up a server, and my client connects and we mess around for a while. Lets say I kill him a few times (goes to my scoreboard), and I pick up new weapons along the way. If another client joins later on, first off the scoreboard is reset (for him), and he will see all the other players with the default starting weapon (baseball bat), even though they might have picked up something different.
So everything appears 'new and fresh' but only for the late comer. Even all the scene rigidbodies are in the default place (even though someone may have moved them).
Whats weird though, is that I have a paintball gun weapon, that does a 'Network.Instantiate' of paintball pellets, and if they have been fired around the scene, and a late comer joins, all the paintballs load into the scene as it looks with every player.
So, my question is, how would I make a late comer (client) load the scene as it actually is?
Hope that makes sense, and thanks!
Hey mate. Couple of questions - are there network views on those rigid bodies? Of have they moved because the simulation on all players games moved them?
Network.Instantiate is doing that AllBuffered thing so those calls all arrive when someone joins late. Are you doing Buffered calls on the others?
Okay, my rigidbodies didn't have a network view, but I just added one and it still doesn't work. The rigidbodies move when a player walks into them (eg: Trash cans). < the client can see the player move the trash whilst he's in the game, but if he leaves, then joins, the trash is in the default position.
Also, I'll look around all my scripts and add a buffer to it. I think its all just a collection of weak coding, most times its forced to load default variables. I'll play around with my weapon system and see what results I can get.
You'd want to sync the transform on those things with rigidbody attached as well I think
Ah wow, I didn't know you could sync the actual rigidbody component, I just assumed that the transform would account for the rigidbody... Well that woks fine now, and I found the problem to my weapon system, there are a lot of Send$$anonymous$$essages to RPCs, and of course this wont add to the buffer will it?
Answer by whydoidoit · May 31, 2012 at 11:42 AM
So you need to add NetworkViews to your rigid bodies so that they are synched between the players - at the moment they appear synced because each game has the participants moving synchronously, however, when a new player joins that hasn't happened for them yet.
When using RPC to communicate things like weapon selection you need to do either:
Buffer the RPC calls so that they are received by each joining participant
or
Pass the state of all other participants when a new player connects with some special player join RPC just to that copy of the game
Can't seem to add my scoreboard to the buffer. The score is stored in an Object.Array, but that shouldn't be a problem should it?
Its getting there, I got a load of RPCs. But anyway, you answered my question so thanks!
I got worried about the buffering thing so just do a state dump for new players - it was probably a bug in my code, but I started getting worried about all of these calls hanging around and playing back contradicting each other. Anyway I felt more in control that way.