Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Unity Multiplayer Adding text to instantiated prefab Only shows on MasterClient

Discussion in 'Multiplayer' started by JD_FVTC, Oct 21, 2020.

  1. JD_FVTC

    JD_FVTC

    Joined:
    Oct 20, 2017
    Posts:
    54
    I'm creating 2 sets of 4 answers for each player to shoot at. But on player 2 the instantiated objects don't show the text. I can only see the text on the master player.

    I can shoot them from player 2's point of view but I can only see the collision on player 1's screen.

    Is there something special to do to get it to show up on player twos screen?

    Code (CSharp):
    1.  
    2. //Call it from some function with this
    3.  this.photonView.RPC("LaunchAnswers", RpcTarget.MasterClient);
    4.  
    5. [PunRPC]
    6.     public IEnumerator LaunchAnswers()
    7.     {
    8.         if (PV.IsMine)
    9.         {
    10.             CancelInvoke();
    11.             int answerCount = 0;
    12.             var angle = .01f;
    13.  
    14.             foreach (GetTheQuestions.Answer answer in theCurrentQuestion.Answers)
    15.             {
    16.                 answerGo = PhotonNetwork.Instantiate(answerfab.name, launcher_Player1[answerCount].transform.position, Quaternion.identity);
    17.                 answerGo.GetComponent<TextMeshPro>().text = theCurrentQuestion.Answers[answerCount].Text;
    18.                 answers.Add(answerGo);
    19.  
    20.                 answerGop2 = PhotonNetwork.Instantiate(answerfab.name, launcher_Player2[answerCount].transform.position, Quaternion.Inverse(Quaternion.identity));
    21.                 answerGop2.GetComponent<TextMeshPro>().text = theCurrentQuestion.Answers[answerCount].Text;
    22.                 answers.Add(answerGop2);
    23.  
    24.                 answerCount++;
    25.                 answerGop2.GetComponent<RotateAroundAnObject>().angle += angle;
    26.                 answerGo.GetComponent<RotateAroundAnObject>().angle += angle;
    27.                 angle += .1f;
    28.  
    29.                 yield return new WaitForSeconds(0.1f);
    30.             }
    31.  
    32.          
    33.         }
    34.      
    35.  
    36.     }
     
    Last edited: Oct 21, 2020