- Home /
Accessing information and checking who's who in network game.
I'm working on a Tower Defense game at the moment and I've implemented the LAN multiplayer function (which works) but now I'm standing in front of a little problem with getting information from one client to another. Let's say I want to display how many kills every player has on the screen. Now when playing the game the script assumes you (meaning the player) to be player0. Currently I'm trying to add a player object with ID to a list inside the OnConnected() method but the obvious problem here is that the list is not the same for each client :/ so when a third player enters the list would be filled with only 1 player, being himself. How would I go on about this problem ? Is there any way to synchronize this list inside the network game somehow or is there another way of retrieving this info ? The same problem happens again when trying to "save" the info on how many kills a player has made.
Are you using RPC communication or Network.Instantiate at the moment?
I'm using Network.Instantiate to instantiate things like the towers.
edit: I'm using RPC stuff on the multiplayer chat, which I just figured out could give me a way to check which player is who, using the PlayerNode. But that still leaves me with the problem of tracking information of each player in the game.
Answer by whydoidoit · Jun 16, 2012 at 12:03 PM
So using RPC when the player connects to the server have it call an Rpc and pass it's networkViewId. When the server gets this call it can itself call all clients and tell them about the new player and call the newly established client and pass it the ids of all of the other players. With a view id you can get the associated game object, but you could also just hold a dictionary or list of the players.