Renaming 3d text over network.

I am trying to rename 3d text over the players head. The problem is, when a 3 or more players connect, the other clients just displays the default text. The server and current player is only displaying their names.

demo: http://loredev.host56.com/Unity3/projectred2/WebPlayer.html

using UnityEngine;
using System.Collections;

public class cs_PlayerText3D : MonoBehaviour {
	
	private Transform AccountTransform;
	private Transform myCamera;
	private Transform myTransform;
	private TextMesh textMesh;
	private string accountName = "";

	// Use this for initialization	
	void Start()
	{
		textMesh = (TextMesh)gameObject.GetComponent(typeof(TextMesh));
		myTransform = transform;
		myCamera = Camera.main.transform;
		
		if (networkView.isMine)
		{
			if (GameObject.FindWithTag("AccountData"))
			{
				AccountTransform = GameObject.FindWithTag("AccountData").transform;
				accountName = AccountTransform.GetComponent<cs_AccountData>().sAccountName;
			}
			else
			{
				Debug.LogWarning("Cannot find [AccountData] gameobject!!");
				textMesh.text = "Cannont Find Data";
			}
		
			networkView.RPC("fnSetName", RPCMode.All, accountName);
		}
	}
	
	void Update()
	{
		myTransform.rotation = myCamera.rotation;
	}
	
	//===============================================================
	// Networking
	//===============================================================
	[RPC]
	void fnSetName(string msg)
	{
		textMesh = (TextMesh)gameObject.GetComponent(typeof(TextMesh));
		textMesh.text = msg;
		Debug.Log("Set 3D text name: " + msg);
	}
	
	void OnPlayerConnected()
	{
		networkView.RPC("fnSetName", RPCMode.OthersBuffered, accountName);
		//Debug.Log("New player connected.");
	}
	
}
networkView.RPC("fnSetName", RPCMode.All, accountName);

Here you are setting the name for the connected instances, new instances will not set the name.

    void OnPlayerConnected()
    {
        networkView.RPC("fnSetName", RPCMode.OthersBuffered, accountName);
        //Debug.Log("New player connected.");
    }

When a player connects to the server, you are sending the name to all instances. Which is wierd, the server doesn’t know the clients name.

I would handle it like this:

void OnConnectedToServer()
{
    networkView.RPC("fnSetName", RPCMode.AllBuffered, "my player name");
}

so each new connection will send it’s player name when connected to all instances.
And int the ‘fnSetName’ method use networkview.ismine to determine if the object belongs to that instance.

Thanks for the reply. But i already tried.

    void OnConnectedToServer()
    {
        networkView.RPC("fnSetName", RPCMode.AllBuffered, "my player name");
    }

The problem with that is when you join the game. None of the previous names will get changed. I am thinking of storing networkID and user name into a list and every time someone OnConnectToSerer() it will store the data then have the server send that list everyone. Then just pull the data from that. Something like the chat log is using for it’s messages.

networkView.RPC("fnSetName", RPCMode.All, accountName);

Actually, this in the start function should have been allbuffered instead of just all. Problem is late commers wouldn’t get the name unless buffered. At least I think this was the problem.

Hence my fist comment

How do i know which gameobject sent the rpc? :S
so i can find target the 3d text

Straight from the docs, maybe take the time to read it ?
http://docs.unity3d.com/Documentation/ScriptReference/NetworkView.RPC.html