How to prevent weapons from penetrating the wall?

I’m creating an FPS and the problem I’m currently having is that the weapon in the hands of my character are penetrating the wall if you get close. I’d like either the hands to back off so that you just see the wall if you come any closer (ideally) or simply to not allow the character to go closer than the end of the gun (I guess this would be easier and it should be enough for a temporary fix). How may I achieve either?

As for the latter, I tried resizing the capsulecomponent of my character but it created a lot problems cause:
a) not all the weapons are the same length
b) I couldn’t figure out how to make the capsule fit tightly and as a consequence you couldn’t walk through narrow doorways

What is the easiest solution to the penetration problem? I thought about attaching a volume to the end of each weapon in their blueprints and then somehow checking if it’s colliding with a wall and if so, blocking the W key. Anything better?

No ideas? :frowning:

Add a collision shape to your weapon and in Blueprints you can check if your weapon is overlapping with any meshes. If it is then play weapon holstering animation in character.

Thank you. Currently I don’t have the animations at hand so I decided to just not allow the player to run the weapon into wall - when I create a box component around my weapon, though, and I set it to block all except for pawn, it doesn’t change anything and it’s still possible to run into the wall with the gun… Why?

Could someone please help me and say how to make the weapon unable to penetrate the wall? I tried creating different shapes around it and using all possible collision settings for them but it goes through the wall anyway when we’re close.

Maybe because it is a child of the pawn?

Tigro, would you mind not bumping your threads before they are unanswered a while? At least 24h if not more.

With bumping every hour, you make it hard for other threads to be seen at all.

It would be helpfull for others if you would always post screenshots of your setup. No one can tell you what you are
doing wrong if we can’t see what you are doing at all (:

@HaxO - you mean the weapon mesh? No, it’s in a separate blueprint.

@eXi - Yes, sure, sorry :slight_smile:

As for the screenshots, here is what the problem looks like: http://i.imgur.com/Drcf9MB.jpg
And here is a sample fix I tried which doesn’t fix anything: http://i.imgur.com/vn8eZYz.png

Any advice? :frowning:

No ideas? :frowning:

In Unity you can simply render the gun on a different render pass and it will be on top of everything but HUD. In UE4 I also didn’t find a solution for this yet.

This came up recently into another post and the suggested solution was to use custom depth.
Here you go:
[Tutorial] The many uses of Custom Depth in Unreal 4](http://www.tomlooman.com/the-many-uses-of-custom-depth-in-unreal-4/)

I’ve already seen this. But couldn’t find a way to draw the whole object with its actual materials instead of only adding an outline to it.
Would be great if we could disable depth test for opaque materials instead of only translucent ones.

I don’t see how this helps either :frowning: All the tutorials I’ve found (and the one @Kris provided) concentrate on outlines. Would someone be so kind to explain how this helps in case of the whole object?