How do i prevent my weapons to clip through walls and such?
add colliders.
i have tried that
but it just look stupid when the character suddenly stops several meters away from an object
U probably dont no what i mean but
i want the gun to be drawn all the time, and instead of going through objects
I found an article about it but i dont get it to work >_>
http://docs.unity3d.ru/Components/class-Camera.html
Under “Depth Only”
I think you mean, when you get closer to a wall, the guy sways to the left, so it appears as if the character is holding it sideways, thus preventing the clipping?
If so, try a Ray, the closer the gun is to the wall, the more the gun rotates to the left.
I think he’s probably just referring to the typical FPS behavior where whatever the player is holding is rendered using its own render settings so that even if it intersects physically with another object, you won’t see it. (I haven’t looked at the link posted earlier, but I imagine it describes how to do something like this in Unity.)
Most games use the method suggested by AkilaeTribe. Even AAA games such as MW2. Use one camera to render only the gun, and set the clear flags to depth only. Use the another camera to render everything else. This way the gun is always rendered on top.