How do I get my gun to not go through the walls?

I imagine that there will be some way for this to have the weapon in a superior “layer” and not to pierce anything, something like this can be done in unity