In 3d multiplayer fps how can I make the crosshair such that other users can not see my crosshair?
I am making a 3D multiplayer fps game and when I spawn, I can see my own crosshair, which is good, but I can also see other people's crosshair. If I toggle the visibility of the crosshair in culling Mask in camera, then I can either see no one's crosshair, or everyone's crosshair. This is because, I add "Don't see" layer to the crosshair, and when another user comes his crosshair also has the layer "Don't see". I set it such that the camera can not see any crosshair, then I do this : if (isLocalPlayer) { // Makes crosshair visible cameraComponent.cullingMask |= 1 << LayerMask.NameToLayer("DontDrawCrosshair"); } When this happens, my crosshair as well as other user's crosshair get visible as it is a clone of the original(mine). The game does not access the internet. It is LAN. Any help appreciated. Thanks!
Answer by PotatoGunStudios · Jan 24, 2017 at 02:15 PM
Add a layer called "Dont Show" by going to layers(top right) --> edit layers
Next to the area where the name of the object is written, there is a drop down called layer. In that select the layer you just made
Got to your camera component in your camera gameobject. In the Culling Mask, select the layer you just added. This will remove that object from play mode.
Make a C# script and attach it to the gameobject. In this, type: using UnityEngine.Networking; public class NAME OF SCRIPT : NetworkBehaviour { void Update() { if (isLocalPlayer) { gameobject.layer = 1; // 1 is default, so it is visible } }
}
Your answer
Follow this Question
Related Questions
Camera culling mask does not work on World Space Canvas 0 Answers
Can't get GUI canvas to show on camera 1 Answer
i am trying to work with wheel collides and i am having some problems 0 Answers
Determine camera distance for object to be completely visible 2 Answers
Exponential Zoom Equation Not Working 0 Answers