How to fix Weapons/ Hands Clipping Into Walls in Unity (URP & SRP)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so you have an FPS game and look at that we don't want this um so yeah I'll show you how to fix this it's actually a fairly common problem in FPS games and there's actually a very easy solution for this so let's get started so what we need to essentially achieve is to render the weapon separately from the map and the rest of the game mode so let's go into our player let's enable our main camera for testing purposes we need to disable this later I usually add a reminder and let's create a new camera so oh by the way if you're using post processing on this main camera like here you're going to want to disable this on the main camera and only enable it on the hand camera so let's rename this too hands no weapon camera to just be clear parents are weapon holder to the weapon camera and for both our weapons we're going to make this a new layer called hand and on the swapping camera for the culling mask that's like nothing and then only select hands and on the main camera for the culling mask let's select everything except for the hand so this camera is rendering the game world and this one is only rendering our weapons right here which is what we want yeah so we currently do not see anything so I'll show you how to fix it for the clear Flags let's do depth only and you can see smooth the weapon being cut off here so let's just decrease the neoplane and um yeah there you have it now I'll also quickly show you the setup for the universal render pipeline in case using that instead of the standard render pipeline like I've been using in this tutorial now in urp it's actually a fairly similar principle so you have your main camera that renders your game world so in this case in my game it's all these layers except for hands and then you have your weapon camera which renders only your hands so I have everything unchecked except for hands and for your weapon camera you want these settings so post processing clear depth and you want this to be set to Overlay not this and then for your main camera under stack you want to add your weapon camera disable post processing or else it'll render twice which you don't want and set this as base and yeah there you have it that's how you do it in both the standard render pipeline and urp soon hope that was useful take care see you in the next one
Info
Channel: bananadev2
Views: 3,706
Rating: undefined out of 5
Keywords: unity, unity3d, unity tutorial, unity beginner tutorial, programming tutorial, weapon clipping
Id: J8HB1-IQFxc
Channel Id: undefined
Length: 3min 19sec (199 seconds)
Published: Sun Jul 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.