Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Nick_Rizzo · Feb 09, 2016 at 12:08 PM · c#camerajavascriptmultiplayer

How do I make a Game Object invisible?

Hi, I'm working on a multiplayer project and I want to make it so you can't see certain objects such as your player model but you can see others. I can't do different layers because then all players will only see whats suppose to be seen in first person. How would I go about doing this? Thanks!

Another way to say what I mean is I'm using the layer trick to make the guns not clip through the walls. How can I make it so I can't see the other players gun through the wall. I tried this but It didn't work public class PlayerSetup : NetworkBehaviour { [SerializeField] Behaviour[] componentsToDisable; GameObject[] gunl; GameObject[] mp; void Start () {

         if (!isLocalPlayer)
         {
             gunl = GameObject.FindGameObjectsWithTag("gun"); 
             mp = GameObject.FindGameObjectsWithTag("mp");
             for (int i = 0; i < componentsToDisable.Length; i++)
             {
                 componentsToDisable[i].enabled = false;
             }
             for (int a = 0; a <= gunl.Length; a++)
             {
                     gunl[a].layer = 0;
 
             }
 
             for (int c = 0; c <= mp.Length; c++)
             {
                 mp[c].layer = 0;
                 
             }
         }
     }
 }
 
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vagonn · Feb 09, 2016 at 03:49 PM 0
Share

you can make gameobject invisible like this. Give different tags to player and other players

  GameObject player = GameObject.FindGameObjectWithTag ("player");
     player.GetComponent<$$anonymous$$eshRenderer>().enabled = false;
 
     GameObject[] otherPlayers = GameObject.FindGameObjectsWithTag ("otherPlayer");
     foreach(GameObject item in otherPlayers)
     {
          item.GetComponent<$$anonymous$$eshRenderer>().enabled = true;
     }



1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Nick_Rizzo · Feb 10, 2016 at 09:16 AM

I found out the answer before the question got approved (like a week) sorry about that... Here's what I came up with probably works better with a loop or something but it works for me, using UnityEngine; using System.Collections; using UnityEngine.Networking;

 public class PlayerSetup : NetworkBehaviour
 {
     [SerializeField]
     Behaviour[] componentsToDisable;
     public GameObject thief;
     public GameObject gun;
     public GameObject body;
     public GameObject bottoms;
     public GameObject eyes;
     public GameObject gloves;
     public GameObject mask;
     public GameObject shoes;
     public GameObject tops;
     public GameObject mag;
     public GameObject sights;
     public GameObject bodyA;
     void Start ()
     {
 
         if (!isLocalPlayer)
         {
             for (int i = 0; i < componentsToDisable.Length; i++)
             {
                 componentsToDisable[i].enabled = false;
             }
         }
         if (isLocalPlayer)
         {
             body.layer = 28;
             bottoms.layer = 28;
             eyes.layer = 28;
             gloves.layer = 28;
             mask.layer = 28;
             shoes.layer = 28;
             tops.layer = 28;
             thief.layer = 28;
             gun.layer = 30;
             mag.layer = 30;
             sights.layer = 30;
             bodyA.layer = 30;
         }
     }
 }
 
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Online Player Position 1 Answer

Multiple Cars not working 1 Answer

Visibility of objects 2 Answers

Unity editor style camera script 1 Answer

Multiplayer Support for Android 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges