Author Topic: Player data  (Read 1725 times)

Noi14

  • Jr. Member
  • **
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 57
    • View Profile
Player data
« 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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Player data
« Reply #1 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.