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*.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;
}
}
}
}*
```
you can make gameobject invisible like this. Give different tags to player and other players GameObject player = GameObject.FindGameObjectWithTag ("player"); player.GetComponent<MeshRenderer>().enabled = false; GameObject[] otherPlayers = GameObject.FindGameObjectsWithTag ("otherPlayer"); foreach(GameObject item in otherPlayers) { item.GetComponent<MeshRenderer>().enabled = true; }
– Vagonn