- Home /
Projectors are supposed to go through objects?
I have a crosshair material being rendered from a gun model with a projector. Works great but the only problem is the projector goes through objects. I read around a bit and apparently this is normal for a projector to do. I know you can use layers to determine what a projector is rendered on but this won't do for a crosshair that's supposed to be rendered on everything.
Is a projector just not the right method to do this? Would a spot light using a custom shape work better? I know I can use a line renderer but I'd like to use a crosshair if at all possible.
Answer by drex150 · Jul 16, 2014 at 08:02 AM
Personally I would just use a GUI Texture. Go here to find out more about it: http://docs.unity3d.com/Manual/class-GuiTexture.html
What you want to do is make your crosshair graphic, then put it in to a GUITexture (GameObject > Create Other > GUI Texture). Slap your crosshair graphic in to it, change the height and width to the right size.
Now the slightly tricky part is, on the x and y you need to adjust those to be exactly half the size of your texture. This is because the texture most likely imported in with the bottom left corner as the pivot point. This means that if you leave the x and y at 0 the graphic will be off center. For example, if you have a graphic that is 32 x 32 height and width, you want the x and y to be -16 x -16. This should put the graphic dead center if your screen.