- Home /
how can I Make my player model invisible to my camera
Im trying to do a online fps game and when I rotate my camera so I can see my body and my face, so how can i make all my player model be invisible only to my camera. I mean that other players will see my player model but my camera will not see my body. please help. (sorry for bad English)
Comment
Best Answer
Answer by SteenPetersen · Feb 20, 2019 at 06:54 PM
Your camera has a culling mask with all your layers, you can try and set the layer that has your player in it to not be rendered by the camera.
You could even do this at runtime if you only want it for certain situations.
using UnityEngine;
public class ExampleClass : MonoBehaviour
{
Camera cam;
int _mymask;
void MyFunction()
{
// Store a copy of your cullingmask
_myMask = cam.cullingMask;
// Only render objects in the first layer (Default layer)
cam.cullingMask = 1 << 0;
// do something
}
}
then you can alwayss et it back to whatever it was by calling:
cam.cullingmask = _myMask;
i'm new, how do i put this code into unity, in what script
Your answer
