networkView.RPC issue for TextMesh

Hey Folks,

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 ! :smile:

Cheers!

Dawnreaver

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.

Thanks for the reply!

I think I tried that as well … I’ll have another go when I’m home.

Is there anything I might do wrong in regards to the way I build the RPC function?

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.

So I tried it and it is still not working. All players on either the server or the client have the same name :frowning:

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.

Fixed It! Thanks for the Help!

np.
It’s good that you describe here how it’s fixed because if someone find it after search or in another way, might learn from it.

Can you please post it, here ! :frowning: