system
1
I'm using one prefab as a user character in multiplay game.
If 5 users connected, each character's names are as below.
Prefabname(Clone)
Prefabname(Clone)Remote
Prefabname(Clone)Remote
Prefabname(Clone)Remote
Prefabname(Clone)Remote
I want to give different name to each character.
Anyone has idea?
You could do you own instantiating(see here http://unity3d.com/support/documentation/ScriptReference/Network.AllocateViewID.html), and send the name of the player as a parameter in the RPC call. And then set the name of the gameobject when you add it.
Does that solve your problem?
Slightly modified sample code from scripting reference:
var cubePrefab : Transform;
function OnGUI ()
{
if (GUILayout.Button("SpawnBox"))
{
var name = "John";
var viewID = Network.AllocateViewID();
networkView.RPC("SpawnBox", RPCMode.AllBuffered,viewID, transform.position, name);
}
}
@RPC
function SpawnBox (viewID : NetworkViewID, location : Vector3, name : String)
{
// Instantate the prefab locally
var clone : Transform;
clone = Instantiate(cubePrefab, location, Quaternion.identity) as Transform;
clone.name = name;
var nView : NetworkView;
nView = clone.GetComponent(NetworkView);
nView.viewID = viewID;
}