- Home /
Prevent Weapon From Going Into Surrounding Graphics
If any of you have played any of the Call Of Duties - you will notice that when you walk up to a wall (for example) - your weapon doesn't go into the wall, it remains completely visible. Where as my weapon in Unity, when I walk up to a wall or something else, my weapon goes into the graphics.
How do they prevent that from happening? Any ideas would be fantastic.
Thanks All!
Already asked and answered here: http://answers.unity3d.com/questions/10620/always-render-a-object-on-top-of-another
Answer by Pirating · Mar 02, 2013 at 06:49 PM
Put your gun in new layer (eg. "Weapon").
Duplicate your main camera.
In it's Culling Mask, check "Nothing", and then check your weapon layer. (now the camera should show your weapon only).
Set your modified camera's Depth to 1.
Enjoy!
Answer by Tyler Alvis · Jan 16, 2011 at 04:24 AM
Put a collider on your character that is big enough for your gun too, so it is one big collider including the player and the gun
Answer by Justin Warner · Jan 16, 2011 at 12:33 AM
Clearly you played to many crappy Call of Duty games, in CoD2, CoD1, and UO, they all go through the walls... The only decent one after this was MW1... All the other blow...
BESIDES THE POINT, you put a collider on the gun, I prefer capsule or cylinder like.
But that should work =).
lol - this will just prevent the the weapon from hitting the wall at all - in COD, you can still face the wall - face to wall - and the weapon still appears complete.
So this wont work
In first person - the weapon against a wall still shows complete okay? But in third person - you can clearly see the weapon going into the graphics (just so you get a better idea)
Eh, when I did it FP, it worked fine, and has worked for others...You never really said TPS, and all the CoD's are First Person, so I guess that's your fault, but w/e.
Did you really downvote his answer just because he didn't like CoD?
Answer by Shealei · Jul 16, 2011 at 10:16 PM
Make the weapon a GUI. That should solve all your problems. Add appropriate animations for fire and reload by removing GUI and adding it back up. Although you can also add the weapon some collider.
Answer by oystarr2g · Oct 03, 2012 at 09:48 PM
puttin a coliider on the gun DOESNT WORK! if it does for you please explain how , in detail. the layer/cam method works but i cannot use a zoom/aim function for my FPS cuz itl show two guns on the screen!. someone pls help isomet ime now ve been tryin to fix this for quite a while now
Your answer