Support => TNet 3 Support => Topic started by: Noi14 on February 27, 2014, 12:54:34 PM
Title: Player data
Post by: Noi14 on February 27, 2014, 12:54:34 PM
Hi, I don't understand how to write data attribute of currently player in order to it is visible to other player. I'm writing:
void Start()
{
TNManager.player.data="team0";
}
If I start it with other client:
foreach(Player player in TNManager.players)
{
Debug.Log(player.data);
}
But I have null as value
Title: Re: Player data
Post by: ArenMook on February 27, 2014, 07:18:26 PM
"Start" is just a generic function that gets executed everywhere, so careful with it.
TNManager.player.data simply sets a variable. This doesn't get synchronized. It's only there for you to keep track of things, like adding a local reference to some custom player class. If you want to synchronize per-player data, do this:
1. When a new player joins a channel, have him TNManager.Create a prefab that has a custom script attached that has all the data you want sync'd. 2. Inside that script, sync what you need via RFC targeting AllSaved or OthersSaved.