Is there a way to specify gameobjects for the camera to ignore? I know you can set layers to each of these objects, but if I HAVE to do layers is it possible to set the layer for each gameobject locally to the network player?
For player 1 Apple’s layer would be 8, while for player 2 Apple’s layer would be 9?
Thanks
Sure
void Start()
{
gameObject.layer = Network.isServer ? 8 : 9;
}
Could you explain to me what you did?
I looked up the operator ?: and I don’t think it’s 100% what I need. My game is a first person styled game and each player’s camera is on the player model. Where the camera is position players see the inside of their body because the camera is in it, the logical solution to this is do what almost every first person game does - make the camera not render the player’s body, only render everyone else’s body.
I need a “system” to be able to let players know what layers they should and shouldn’t be rendering to apply this effect.
Also, do I need 1 layer for each player or is there a much better solution to going about with this?
Why don’t you just delete the player model if the camera belongs to the player? That’s the more common approach. If a spawning player is remote then spawn a full player model otherwise just spawn a camera.
If you really need/want to use layers then all you need are two. One for “me” and one for “not me”. What goes in those layers will differ from player to player but the concept is the same across the board.
To answer your other question - ? is a ternary operator and is more or less just a method for condensing an if-else statement to one line. I could also do this
if (Network.isServer)
gameObject.layer = 8;
else
gameObject.layer = 9;