FPS View Bug

Im working on a FPS game, and so far everything goes fine.

But I have this problem, that I dont know how to fix.

I followed the FPS tutorial, and it dosn’t seem to say anything about this. Yet, in their example this dosn’t happen.

Maybe you can give the weapon a collider. So it detects it.

Typically this is handled by having a separate camera that renders the weapon on top of everything else.

–Eric

Thats what thought! After messing with COD5, I realized that COD5 does that.

But how do I do that in UNITY?

Make a camera that only renders the gun (using layers), then set the clear flags to depth only and have it be a higher priority than the main camera. Parent that to the main camera, which should use layers to not render the gun.

–Eric

Thanks Eric, it works perfect now!

Theres a problem now. I opened Unity today, to continue working, and now the weapon is not seen.

It is only seen if i turn the “weapon camera” off and then back on. During ingame test or in editor’s “game view”

But only works until i do something else.

The built projects has the problem too.

I think its because of the priority, maybe the Main camera is renderinga above the weapon, thats why I cant see it.

How do change that priority? Or fix the problem if its not that?

edit: I changed the Depth in weapon camera to 1, now it seems to work ok. Because I built the project and it does work in standalone.

Is that supposued to fix it? Or is it just for a while like before?