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
  • Ігри

КОМЕНТАРІ • 82

  • @nivcube
    @nivcube Рік тому +3

    This is what I've been looking for! What a lifesaver! Keep up the work bro

  • @roaddust
    @roaddust Рік тому

    I re-watch this same video every time I have to fix this issue. Can't thank you enough!!

  • @thealexiscoolshow8370
    @thealexiscoolshow8370 2 роки тому +6

    This is very helpful and you explain it really easily

  • @cammo9104
    @cammo9104 2 роки тому

    Thank you! You're a life saver I could not find a quick fix to the issue.

  • @user-yx2ui3db6t
    @user-yx2ui3db6t Рік тому

    Thanks a lot , a new thing learned from you and I was searching for it !

  • @Ejhaz09
    @Ejhaz09 2 роки тому +1

    Thankyou for the tutorial , it helped me with this issue as a beginner!

  • @salazarthur1832
    @salazarthur1832 Рік тому

    Thanks a lot. i watched 10 tutorials or so just for this one to be working

  • @fazin85
    @fazin85 Рік тому

    tysm! better than all the other tutorials

  • @EpicSqu1rrel
    @EpicSqu1rrel 3 місяці тому

    nicely done, thanks!

  • @hisuii
    @hisuii Рік тому

    Thanks. No need for URP or anything else that other guides on this say. Great stuff

  • @Mot0Mot0
    @Mot0Mot0 8 місяців тому

    Came to this video a second time and still the only one that worked

  • @asasin8129
    @asasin8129 Рік тому +1

    Thank you man you helped me a lot!

  • @real_linkw0w
    @real_linkw0w Рік тому

    thx you bro i finally got it thank you so much !!!

  • @theanimatronicgamerreturn7785
    @theanimatronicgamerreturn7785 3 роки тому +1

    Very useful bro! Well done!

  • @onestepdown2475
    @onestepdown2475 2 роки тому

    tysm! you deserve more subscribers

  • @gmangman123
    @gmangman123 Рік тому

    Thx so much my friend!

  • @tamvo5557
    @tamvo5557 Рік тому

    Great, thanks bro

  • @agent_vucko
    @agent_vucko Рік тому

    Man, you are legend

  • @rajeshsaini796
    @rajeshsaini796 8 місяців тому

    Keep it up.....bro❤❤❤❤

  • @WishDog_
    @WishDog_ 8 місяців тому

    thank you this made my game look better. I recomend this to every new unity user

  • @caverians
    @caverians 2 роки тому

    thanks bro it helped a lot

  • @dunderguy
    @dunderguy Рік тому

    Thank you so much

  • @dilshangunawardena2717
    @dilshangunawardena2717 Рік тому

    Thank god man you save my project ❤❤❤❤❤❤😍😍

  • @sleepyminecart6182
    @sleepyminecart6182 10 місяців тому

    thank you very much

  • @mr-mayo7168
    @mr-mayo7168 Рік тому

    Very nice

  • @fokus5097
    @fokus5097 Рік тому

    Thanks!

  • @SinghMandeep13
    @SinghMandeep13 3 роки тому +1

    Thank you now I can solve this bug in my fps game😁😁😁😁

  • @Serious_Im
    @Serious_Im Рік тому

    Thanks a lot

  • @foolauto915
    @foolauto915 2 роки тому

    man u are basically a god bro

  • @MatanNaveh
    @MatanNaveh 2 роки тому

    Thanks bro!

  • @Lulpe
    @Lulpe 2 роки тому

    Thanks dude

  • @Mot0Mot0
    @Mot0Mot0 Рік тому

    thank you

  • @scottmedhaug4107
    @scottmedhaug4107 Рік тому

    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

  • @denizdemir9255
    @denizdemir9255 2 роки тому

    thanks bro!

  • @henokgetnet6068
    @henokgetnet6068 Рік тому

    awesome it worked

  • @googleuser7506
    @googleuser7506 Рік тому

    Thanks

  • @andrew.s8.enjoyer
    @andrew.s8.enjoyer 2 роки тому +1

    omg tysm!

  • @user-mz8ex4iv3z
    @user-mz8ex4iv3z 2 роки тому

    Thank you

  • @breadthegod7192
    @breadthegod7192 4 місяці тому

    ur so cool, ty

  • @lifesymbiont5769
    @lifesymbiont5769 2 роки тому

    thanks

  • @bagutei
    @bagutei Рік тому

    tysm

  • @fc2004-pj7hr
    @fc2004-pj7hr 2 місяці тому

    bro you fucking life saver. i have been trying this shit for 3 days. it finally worked.

  • @Modrex.Dev0
    @Modrex.Dev0 11 місяців тому

    Thank so much me Friend

  • @guyclegg
    @guyclegg 2 роки тому

    great

  • @vrcookingsimulator5458
    @vrcookingsimulator5458 3 роки тому +8

    Very cool. Do you know how to do the physics collision type of no clipping weapons. Where the gun pulls back into the player.

    • @SkyYurt
      @SkyYurt  3 роки тому

      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

    • @alter-boy
      @alter-boy 3 роки тому +5

      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.

  • @CoolAndChillZigglot
    @CoolAndChillZigglot Рік тому

    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?

  • @12edcorea54
    @12edcorea54 2 роки тому

    thx

  • @RetroMaid
    @RetroMaid Рік тому

    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?

  • @LimusOficial
    @LimusOficial 2 роки тому +2

    Shadows gone, how to fix?

  • @Cyb11893
    @Cyb11893 2 роки тому +2

    Where has the shadow gone? And this method does not work with shadows.

  • @watercat1248
    @watercat1248 2 місяці тому

    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.

  • @dgbro524
    @dgbro524 5 місяців тому

    How can I fix the RayCast goes through the wall or other object?

  • @user-fy4wm6fn3b
    @user-fy4wm6fn3b Місяць тому

    LOVE UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @mikifufu
    @mikifufu 3 роки тому +2

    An hypothetical player on the other side of the wall, will be able to xe the tip of the gun or not?

    • @SkyYurt
      @SkyYurt  3 роки тому +1

      Yes they would

  • @playerplus5917
    @playerplus5917 2 роки тому +5

    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

  • @Schytheron
    @Schytheron 3 роки тому +2

    Does this have a performance hit (since you're using 2 cameras)?

    • @SkyYurt
      @SkyYurt  3 роки тому +1

      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

  • @blinkachu5275
    @blinkachu5275 Рік тому +1

    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

    • @stylie473joker5
      @stylie473joker5 Рік тому +1

      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

    • @egeyaman4074
      @egeyaman4074 9 місяців тому

      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

  • @JeremyHoffman
    @JeremyHoffman 3 роки тому +1

    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?

    • @SkyYurt
      @SkyYurt  3 роки тому

      Exactly

    • @willow_d
      @willow_d 3 роки тому

      He also made 2nd camera to render it's image after the 1st camera, so that they overlay and we get our result.

  • @ze1st_
    @ze1st_ Місяць тому

    just make weapon small and close to the camera so thats stays in collider. Player wont see a difference.

  • @YajatKaul
    @YajatKaul Рік тому

    y not just add rigidbody and collider?

  • @longjohn7992
    @longjohn7992 2 роки тому

    What if it’s Multiplayer

  • @spyschannel8000
    @spyschannel8000 2 роки тому

    Thanks bro, you talk slowly like a sloth but your tutorial is good

  • @lazikbro12
    @lazikbro12 2 роки тому

    For me not works

  • @AZASeraph
    @AZASeraph 2 роки тому

    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

  • @knos2938
    @knos2938 2 роки тому

    Did not work

  • @DARK_AMBIGUOUS
    @DARK_AMBIGUOUS 2 роки тому +2

    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

  • @taratraptaratrap8394
    @taratraptaratrap8394 2 роки тому +2

    Nice copy of the brackeys tutorial

  • @V1king_Person
    @V1king_Person 2 роки тому

    Thanks!

  • @_farooq_zahid
    @_farooq_zahid Рік тому

    thanks

  • @Hervoo
    @Hervoo 3 роки тому

    Thanks

  • @__Rizzler__
    @__Rizzler__ 10 місяців тому

    thanks

  • @essamdob2
    @essamdob2 4 місяці тому

    thanks

  • @bandrufilms
    @bandrufilms 2 роки тому

    thanks