Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party Photon Setactive cloth

Discussion in 'Multiplayer' started by brano42, Apr 6, 2022.

  1. brano42

    brano42

    Joined:
    Aug 25, 2020
    Posts:
    78
    Hello i have a problem i and other player have same cloth even though we don't have the same clothes someone help my wiht script?
    Here is my script

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Photon.Pun;
    5.  
    6. public class ClothsPlayer : MonoBehaviour
    7. {
    8.     public int num1;
    9.     public int num2;
    10.     public int num3;
    11.     public int num4;
    12.  
    13.     public GameObject[] top;
    14.     public GameObject[] pant;
    15.     public GameObject[] sock;
    16.     public GameObject[] boty;
    17.  
    18.     public PhotonView photonView;
    19.     // Start is called before the first frame update
    20.    private void Awake()
    21.     {
    22.    
    23.  
    24.    
    25.  
    26.  
    27.         photonView.RPC("SetactiveCloth", RpcTarget.AllBuffered, num1,num2,num3,num4);
    28.  
    29.  
    30.    
    31.  
    32.  
    33.     }
    34.     [PunRPC]
    35.     private void SetactiveCloth(int num1, int num2, int num3, int num4)
    36.     {
    37.         num1 = PlayerPrefs.GetInt("ClothSave1");
    38.         num2 = PlayerPrefs.GetInt("ClothSave2");
    39.         num3 = PlayerPrefs.GetInt("ClothSave3");
    40.         num4 = PlayerPrefs.GetInt("ClothSave4");
    41.         for (int i = 0; i < top.Length; i++)
    42.  
    43.             top[i].SetActive(i == num1);
    44.         for (int i = 0; i < pant.Length; i++)
    45.  
    46.             pant[i].SetActive(i == num2);
    47.         for (int i = 0; i < sock.Length; i++)
    48.  
    49.             sock[i].SetActive(i == num3);
    50.         for (int i = 0; i < boty.Length; i++)
    51.  
    52.             boty[i].SetActive(i == num4);
    53.  
    54.     }
    55.  
    56. }
    57.  
     
    Last edited: Apr 6, 2022
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    This code never initializes photonView.
    To get better input, you need to explain what your problem is.
     
  3. brano42

    brano42

    Joined:
    Aug 25, 2020
    Posts:
    78
    player 1 have cloth 1 and player 2 have cloth 2 but if i log in online so script SetActive player 1 and player2 have same cloth 1.... sorry for my english please help me
     
  4. brano42

    brano42

    Joined:
    Aug 25, 2020
    Posts:
    78
    Thank you my problem is done
     
  5. Chumzy_01

    Chumzy_01

    Joined:
    Apr 26, 2020
    Posts:
    3
    How did you solve it?