- Home /
The question is answered, the (kinda) right answer was accepted
Unity Networking synchronize 3DText's
Hello guys, I am currently stuck working on a 2D game, a little bit like 'realm of the mad god' but that's not important, the important thing is, I am instatiating a character (from a Prefab) and it's working fine with the "NetworkView" in-built component from unity, however, I like to synchronize a players nametag and the chat below as well, but I just can't think of a proper way to do so in Unity (It`s my first time in Unity making something for Network).
Here's how I call the NameTag Change from the mainscript:
CharacterScript.SetTag(playerName, level);
Here's the script from inside the CharacterScript:
public static void SetTag(string name, int level)
{
playerLevel = level;
playerName = name;
}
So, how can I synchronize this that it's being changed for every user (not just for each client)
(If you don`t really get what I am trying to achieve, imagine in RPG`s where you have the playerlevel above each player, that`s what I want, well and more..)
Any help is appreciated. :)
Sorry, what I meant is, that currently only your own 3DText is gonna change, the 3DText from any other users remain the default variable. :I
Answer by perchik · Jul 26, 2013 at 06:17 PM
I would make SetTag an RPC function:
[RPC]
public void SetTag(string name, int level)
{
playerLevel= level;
playerName = name;
}
and call it :
networkView.RPC("SetTag", RPCMode.All, pName, pLevel);
Yeah I figured it would work with RPC`s but I tried the following:
networkView.RPC ("UpdateLabels", RPC$$anonymous$$ode.All);
within the CharacterScript (which is attached to the player prefab)
But as a result it changes everyone`s 3Dtext to the same, it`s always the playername of the player connected above everyones head, (example, if the player's name is "George" every other player has "Lv1 - Goerge" above his head, but on another player`s screen, whose name is "Steve", there would be "Lv1 - Steve" above each players head.. very confusing :I
Follow this Question
Related Questions
SyncVar issue 0 Answers
Networking Sync SetActive Not Working 0 Answers
Animating online users sprite 0 Answers
[Error] RPC function undefined in IRRELEVANT file? 0 Answers
Can I use Rpc Calls and Commands on the same object? 0 Answers