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

Making an object invisible to player, but not other players.

Discussion in 'Scripting' started by spencer_white, Oct 3, 2016.

  1. spencer_white

    spencer_white

    Joined:
    Nov 9, 2015
    Posts:
    37
    Hi. I want to be able to add an object on to a player (inconveniently, in front of the camera.) The object shows up, but I can't make it invisible, since I want other players to be able to see this object. Can someone help?
     
  2. takatok

    takatok

    Joined:
    Aug 18, 2016
    Posts:
    1,496
    Assuming this is a Networking game and your using Unity's Unet to handle spawning all these objects on each of the clients and the host. You could utilize the isLocal feature of a NetworkBehaviour. Make sure the object is the child of hte player. Then in the player's Start() script get a handle to that child object and check if the player.IsLocal. This will be true on the machine that is the player. So if its true set the Image.enabled = false; Then it won't show up locally. On everyone else's machine the Player object that is spawned for them will have isLocal=false and so it won't disable the image.
     
  3. spencer_white

    spencer_white

    Joined:
    Nov 9, 2015
    Posts:
    37
    Oh, ok! Thanks!
     
  4. spencer_white

    spencer_white

    Joined:
    Nov 9, 2015
    Posts:
    37
    Sorry, I've been trying this for a while, and can't seem to get it to work. Could you tell me how to make this?
     
  5. FabriBertani

    FabriBertani

    Joined:
    Jul 18, 2016
    Posts:
    12
    Put the object in different layer and make the player camera ignore that layer.