Tasharen Entertainment Forum

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:
  1. void Start()
  2. {
  3. TNManager.player.data = "team0";
  4. }

If I start it with other client:
  1. foreach(Player player in TNManager.players)
  2. {
  3. Debug.Log(player.data);
  4. }

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.