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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[Help!] Multiplayer - Making Your Name Only Visible To Other Players

Discussion in 'Scripting' started by ExbowFTW, Jun 22, 2015.

  1. ExbowFTW

    ExbowFTW

    Joined:
    May 2, 2015
    Posts:
    281
    Hey guys -

    Currently I have my multiplayer game running so that any player's name (a TextMesh) is right above his/her head, and is visible to all players, even to himself/herself.

    However, it is annoying that the only person can see his own name above his head. Therefore, is there a way to use Layers to make sure that each person can see eveyone else's name, but can't see their own name?

    I tried doing it, but it seemed very logically complicated...

    If you have any suggestions or ideas, PLEASE post them down below. I would love any help! Thanks!

    Exbow
     
  2. RiokuTheSlayer

    RiokuTheSlayer

    Joined:
    Aug 22, 2013
    Posts:
    356
    If there's a way to tell if a gameobject is another player's or yours (Like Photon's PhotonView.isMine) then you can just make a script that disables the TextMesh gameobject if the player it's "following" isn't yours. It'd just be 2+ lines depending on your setup. I haven't played with unity's built-in networking so I don't know if it has something like this.
     
  3. Mabenan

    Mabenan

    Joined:
    Feb 7, 2014
    Posts:
    132
    The question is which multiplayer you use rakNet (old) or unet (new).

    In rakNet it is networkView.isMine.

    In unet it is GetComponent<NetworkIdentity>().isLocalPlayer.
     
  4. ExbowFTW

    ExbowFTW

    Joined:
    May 2, 2015
    Posts:
    281
    Omg I never thought of that before.. I have Photon so that will work perfectly.

    Thank you so much ! <3
     
  5. ExbowFTW

    ExbowFTW

    Joined:
    May 2, 2015
    Posts:
    281
    thanks
     
  6. ExbowFTW

    ExbowFTW

    Joined:
    May 2, 2015
    Posts:
    281
    I use Photon, so Rioku's should work. Thanks for all the help Mabenan :)