Prevent Weapons from Clipping through Walls in 2 mins (Unity Tutorial)
Вставка
- Опубліковано 14 лип 2024
- Need help or want to share your work. Join our Discord:
/ discord
In this short tutorial I show you how you can prevent weapons in FPS games from clipping through walls.
If you are making an FPS game it is a very common problem that the weapons clip through walls. However, it is fairly easy to fix this problem.
00:00 The Problem
00:29 The Solution
01:50 The Result
Twitter: / skyyurt
Discord: / discord
#Unity #Tutorial #FPS - Ігри
This is what I've been looking for! What a lifesaver! Keep up the work bro
I re-watch this same video every time I have to fix this issue. Can't thank you enough!!
This is very helpful and you explain it really easily
Thank you! You're a life saver I could not find a quick fix to the issue.
Thanks a lot , a new thing learned from you and I was searching for it !
Thankyou for the tutorial , it helped me with this issue as a beginner!
Thanks a lot. i watched 10 tutorials or so just for this one to be working
tysm! better than all the other tutorials
nicely done, thanks!
Thanks. No need for URP or anything else that other guides on this say. Great stuff
Came to this video a second time and still the only one that worked
Thank you man you helped me a lot!
thx you bro i finally got it thank you so much !!!
Very useful bro! Well done!
Thank you
tysm! you deserve more subscribers
Thx so much my friend!
Great, thanks bro
Man, you are legend
Keep it up.....bro❤❤❤❤
thank you this made my game look better. I recomend this to every new unity user
thanks bro it helped a lot
Thank you so much
Thank god man you save my project ❤❤❤❤❤❤😍😍
thank you very much
Very nice
Thanks!
Thank you now I can solve this bug in my fps game😁😁😁😁
Thanks a lot
man u are basically a god bro
Thanks bro!
Thanks dude
thank you
my main camera wasn't a child of my Player but I used the virtual camera as the main Camera and it worked well. I did have to delete and remove the information from the main camera so it wouldn't show the weapon but it worked great. thank you
thanks bro!
awesome it worked
Thanks
omg tysm!
Thank you
ur so cool, ty
thanks
tysm
bro you fucking life saver. i have been trying this shit for 3 days. it finally worked.
Thank so much me Friend
great
Very cool. Do you know how to do the physics collision type of no clipping weapons. Where the gun pulls back into the player.
Thank you. You'll probability need to add a rigidbody to the weapon and move it around using force on the rigidbody instead of moving the transform. Haven't tried it out myself
I wouldn't do a Physics Collision, I would have a ray coming out near the weapon and detecting the Ray Cast hit on something in front of the player, and calculating a distance, where the distance cannot go under a certain threshold and you could lerp, or animate the weapon to be in a certain position/state. When the ray calculation distance goes above, you can revert back to a lerped position or animation state.
Thank you! All the tutorials were using URP and I wasn't thank you you saved my life!
Edit: I just have a problem... I can see the gun through the walls any fix?
thx
in viewport weapo rendering camera is working, but in game it's invisible, when in game i change the fov, it will work.. any solutions?
Shadows gone, how to fix?
Where has the shadow gone? And this method does not work with shadows.
I personally have 4 overly cameras not 1 one for each Player
In my game I have the option to play split screen.
Up to 4 players.
And the name those lawyer's p1 overly and so own.
I also have p1 view and p1 hide from
In the order to hide your own model and make visible from the other player's.
How can I fix the RayCast goes through the wall or other object?
LOVE UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
An hypothetical player on the other side of the wall, will be able to xe the tip of the gun or not?
Yes they would
I've a grappling hook in my Unity project, but when I use it, it doesnt't really hit the objects. Well it hits them, but it's looking at a different place instead of the objects
Does this have a performance hit (since you're using 2 cameras)?
If you make sure the secondary camera only renders the weapon and the primary camera doesn't render it, then you won't have any worthwhile performance hit. You'll only get performance hit, if both you cameras are rendering the same objects
The problem with this is that the weapon won't receive shadows from the environment so sadly this is not a solution that's viable if you care about visual fidelity
In HDRP you can use two custom passes; one of them with Depth test on "always" and the other with Depth test on "Less Equal" to draw the gun over everything and the gun will still receive post processing and such
fps gun should not have a shadow tho, your player model (that is invisible to player itself) should receive shadow, fps camera gun would look weird in third person perspective or in a shadow
I know nothing about Unity, so I'm just gonna guess how this fix works: you've added a 2nd camera that can only "see" the weapon (not the wall, etc). And you've hidden the weapon from the 1st camera. And the net result is that the weapon always appears "in front" of the wall?
Exactly
He also made 2nd camera to render it's image after the 1st camera, so that they overlay and we get our result.
just make weapon small and close to the camera so thats stays in collider. Player wont see a difference.
y not just add rigidbody and collider?
What if it’s Multiplayer
Thanks bro, you talk slowly like a sloth but your tutorial is good
For me not works
Yay now the player can wallbang enemies.
Edit: if you want it to not do that you could make it so that when the weapon touches the wall the player raises it in the air and then can't shoot. Idk how but that'd work
Did not work
But then it gives the subconscious effect of the gun being smaller than it really is, the best solution is to make it where if the front of the player is to close to a wall, it plays an animation of the player pulling and holding the gun towards they’re body a little bit, it looks more realistic and that’s how it would work in real life
Nice copy of the brackeys tutorial
Thanks!
thanks
Thanks
thanks
thanks
thanks