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.
  2. Dismiss Notice

Question How to get player's name when player click button

Discussion in 'Scripting' started by gamer123454321, Nov 26, 2020.

  1. gamer123454321

    gamer123454321

    Joined:
    Mar 25, 2020
    Posts:
    83
    Hi! I'm making to multiplayer game using Mirror. In the scene player can choose characters by clicking the buttons. But I know to how to tell unity which player is clicking on that button. How to get player's name who click the button?
     
  2. gamer123454321

    gamer123454321

    Joined:
    Mar 25, 2020
    Posts:
    83
    I added if (isLocalPlayer) still not work
    Code (CSharp):
    1.  public void BeomeThisCharacter(int num)
    2.     {
    3.         if (isLocalPlayer)
    4.         {
    5.             character.GetComponent<SpriteRenderer>().sprite = characterChoice[num];
    6.             character.AddComponent<Animator>();
    7.             character.GetComponent<Animator>().runtimeAnimatorController = animeControl[num];
    8.         }
    9.     }