RPC problems

I’m trying to add customization to my game. I want to be able to make changes to the spawned character based on data that is stored in playerprefs on the client. So far I have this:

using UnityEngine;
using System.Collections;

public class Instantiate : MonoBehaviour {
	public Transform floatNamePrefab;
	
	public Material skin1;
	public Material skin2;
	public Material skin3;
	public Material skin4;
	
	public Transform playerAvatar;
	public NetworkView playerID;
	public string playerName = "";
	public int playerClass = 0;
	public int playerSkin = 0;
	public Transform PlayerCamera;
	
	void Awake () {
		playerName = PlayerPrefs.GetString("AvatarName", "");
		playerClass = PlayerPrefs.GetInt("AvatarClass", 0);
		playerSkin = PlayerPrefs.GetInt("AvatarSkin", 0);
	}

	void OnNetworkLoadedLevel () {
		// instantiate player when network is established
		if (Network.isClient) {
			GameObject Avatar = Network.Instantiate(playerAvatar, transform.position, transform.rotation,0) as GameObject;
			//NetworkViewID viewID = Network.AllocateViewID();
			Avatar.networkView.RPC("SpawnAvatar", RPCMode.AllBuffered, playerSkin, playerName);
			gameObject.SendMessage("StartUp");
		}
	}

	void OnPlayerDisconnected (NetworkPlayer player) {
		Network.RemoveRPCs(player, 0);
		Network.DestroyPlayerObjects(player);
	}
	
	void OnDisconnectedFromServer () {
		Destroy(GameObject.Find("Player(Clone)"));
		Network.RemoveRPCsInGroup(0);
		//Network.Destroy(GameObject.Find("Player(Clone)"));
	}
	
	[RPC]
	void SpawnAvatar (int skin, string name) {
		GameObject floatName = Instantiate(floatNamePrefab, new Vector3(playerAvatar.transform.position.x, playerAvatar.transform.position.y + 1, playerAvatar.transform.position.z), Quaternion.identity) as GameObject;
		TextMesh TM = floatName.GetComponent("TextMesh") as TextMesh;
		TM.text = name;
		floatName.transform.parent = playerAvatar.transform;
		SkinnedMeshRenderer skinner;
		skinner = playerAvatar.GetComponentInChildren<SkinnedMeshRenderer>();
		if (skin == 0) {
			skinner.material = skin1;
		}
		if (skin == 1) {
			skinner.material = skin2;
		}
		if (skin == 2) {
			skinner.material = skin3;
		}
		if (skin == 3) {
			skinner.material = skin4;
		}
		
		//NetworkView nView1;
		//nView1 = playerAvatar.GetComponent("NetworkView") as NetworkView;
		//nView1.viewID = viewID;
	}
}

Now how do I call the RPC so that the changes is only made to the character that was instanciated in my OnNetworkLoadedLevel method? a lot of things probably has to change in the RPC for this to work correctly. anyone willing to help me understand this?

Wait are you just wanting to spawn whatever model the person has selected?

Or is it the same model with a different skin?

Or are they able to change the model and the skin?

I just need to understand this before I can help and answer what you want exactly.

Hi Cure
Well in my code there only the skin is changed based on what the player has selected. and it also spawns a object that displays the player’s name above them. But I believe I would later change the model too.

So the problem is, whenever someone chooses a skin, EVERY OTHER players skin is that skin?

No, none of the players’ skin changes. The problem is getting a referance to the spawned character to use within the RPC so I can access it and make changes to it. So some kind of ID from which i can access the gameObject in the RPC.

Is what I’m asking making sense?