I have the player name in a text mesh But for some reason only the default name of the text mesh is displayed for all other players, the changed name ( for my own player) is displayed just fine.
static var playerName: String = "Factory Worker"; // can be changed by options
var displayName : GameObject; // the TextMesh
function Start ()
{
if(networkView.isMine)
{
displayName.gameObject.GetComponent(TextMesh).text = playerName;
networkView.RPC("SetMyName",RPCMode.AllBuffered, playerName);
}
}
function Update ()
{
}
@RPC
function SetMyName(myPlayerName: String)
{
myPlayerName = "myName";
}
Any Ideas where I’m at fault ? Sending information in multiplayer is really starting to domy head in !
The reason is simple, in RPC you are receiving the string and setting playerName but then you are not setting 3dTextMesh.text property to the name like what you are doing at Start.
Nothing wrong. You should write any functionality that you require it to do and make it in a way to get enough and correct arguments.
then add RPC attribute.
You did both. The only problem is that you are not setting the 3dtextmesh 's text property after setting the variable myPlayerName.
Put a Debug.Log in your RPC to see if it’s called at all or not. Or you can check the myPlayerName variable to see if it’s changed or not. If called and if you are not reseting the value of the text property of the TextMesh, then it has no reason to don’t work.