Search Unity

Apearance of players with RPC issues

Discussion in 'Multiplayer' started by UnityUser9860, Oct 7, 2016.

  1. UnityUser9860

    UnityUser9860

    Joined:
    Dec 8, 2015
    Posts:
    179
    Hello!

    Ive got a system setup in my multiplayer game to change your appearance based on what u selected in the menu but all the other players the the same as you! heres my script:
    Code (CSharp):
    1. void Start(){
    2. if (isLocalPlayer){
    3.             print ("CMD CHANGE TONE");
    4.             CmdStartRpcChnageTone (gameObject, PlayerPrefs.GetInt("TONE"), PlayerPrefs.GetInt("SHORTS"), PlayerPrefs.GetInt("SHIRT"));
    5.         }
    6. }
    7.  
    8. [Command]
    9.     void CmdStartRpcChnageTone(GameObject ChangeToneOf,int SkinTone,int ShortTone,int ShirtTone){
    10.         RpcChangeTone (ChangeToneOf, SkinTone, ShortTone, ShirtTone);
    11.     }
    12.  
    13.     [ClientRpc]
    14.     public void RpcChangeTone(GameObject ChangeToneOf,int SkinTone,int ShortTone,int ShirtTone)
    15.     {
    16.         //if (isLocalPlayer) {
    17.             Meshrenderers2 = ChangeToneOf.GetComponentsInChildren<SkinnedMeshRenderer> ();
    18.             foreach (SkinnedMeshRenderer body in Meshrenderers2) {
    19.                 if (body.transform.gameObject.name == "Body") {
    20.                     print ("Body1");
    21.                     if (body.transform.parent.name == "Anim" + gameObject.name) {
    22.                         print ("Changing skin tone");
    23.                         //var Tone = PlayerPrefs.GetInt ("TONE");
    24.                         var Tone = SkinTone;
    25.                         if (Tone == 2) {
    26.  
    27.                             TONE = new Color32 (255, 214, 163, 255);
    28.                         }
    29.                         if (Tone == 1) {
    30.  
    31.                             TONE = new Color32 (255, 233, 206, 255);
    32.                         }
    33.                         if (Tone == 0) {
    34.  
    35.                             TONE = new Color32 (255, 255, 255, 255);
    36.                         }
    37.                         if (Tone == 3) {
    38.  
    39.                             TONE = new Color32 (110, 53, 30, 255);
    40.                         }
    41.                         if (Tone == 4) {
    42.  
    43.                             TONE = new Color32 (77, 53, 23, 255);
    44.                         }
    45.                         if (Tone == 5) {
    46.  
    47.                             TONE = new Color32 (34, 22, 7, 255);
    48.                         }
    49.                         body.sharedMaterial.color = TONE;
    50.  
    51.                     }
    52.                 }
    53.  
    54.             }
    55.  
    56.  
    57.  
    58.             //Change Shorts
    59.         Meshrenderers3 = ChangeToneOf.GetComponentsInChildren<SkinnedMeshRenderer> ();
    60.             foreach (SkinnedMeshRenderer body in Meshrenderers3) {
    61.                 if (body.transform.gameObject.name == "Bottoms") {
    62.                     if (body.transform.parent.name == "Anim" + gameObject.name) {
    63.                         var Tone = ShortTone;
    64.                         print ("Bottoms " + Tone);
    65.                         if (Tone == 0) {
    66.  
    67.                             TONE2 = new Color32 (255, 255, 255, 255);
    68.                         }
    69.                         if (Tone == 1) {
    70.  
    71.                             TONE2 = new Color32 (0, 0, 0, 255);
    72.                         }
    73.                         if (Tone == 2) {
    74.  
    75.                             TONE2 = new Color32 (0, 192, 255, 255);
    76.                         }
    77.                         if (Tone == 3) {
    78.  
    79.                             TONE2 = new Color32 (230, 255, 0, 255);
    80.                         }
    81.                         if (Tone == 4) {
    82.  
    83.                             TONE2 = new Color32 (160, 0, 255, 255);
    84.                         }
    85.                         if (Tone == 5) {
    86.  
    87.                             TONE2 = new Color32 (255, 0, 185, 255);
    88.                         }
    89.                         body.sharedMaterial.color = TONE2;
    90.  
    91.                     }
    92.                 }
    93.             }
    94.  
    95.             //Change Shirt
    96.         Meshrenderers4 = ChangeToneOf.GetComponentsInChildren<SkinnedMeshRenderer> ();
    97.             foreach (SkinnedMeshRenderer body in Meshrenderers4) {
    98.                 if (body.transform.gameObject.name == "Tops") {
    99.                     if (body.transform.parent.name == "Anim" + gameObject.name) {
    100.                         var Tone = ShirtTone;
    101.                         if (Tone == 0) {
    102.  
    103.                             TONE3 = new Color32 (255, 255, 255, 255);
    104.                         }
    105.                         if (Tone == 1) {
    106.  
    107.                             TONE3 = new Color32 (0, 0, 0, 255);
    108.                         }
    109.                         if (Tone == 2) {
    110.  
    111.                             TONE3 = new Color32 (0, 192, 255, 255);
    112.                         }
    113.                         if (Tone == 3) {
    114.  
    115.                             TONE3 = new Color32 (230, 255, 0, 255);
    116.                         }
    117.                         if (Tone == 4) {
    118.  
    119.                             TONE3 = new Color32 (160, 0, 255, 255);
    120.                         }
    121.                         if (Tone == 5) {
    122.  
    123.                             TONE3 = new Color32 (255, 0, 185, 255);
    124.                         }
    125.                         body.sharedMaterial.color = TONE3;
    126.  
    127.                     }
    128.                 //}
    129.             }
    130.         }
    131.     }
    132.  
    133.  
    134.  
    ive also tried calling the Cmd function with the isLocalPlayer
    please help thank you!