Weapon overlaping the wall

I have created character and i added socket to its right hand and i have put pistol there.

The issue is in wepon overlaping the walls. Here are the pictures :

This is my character’s blueprint:

As you can see I added capsule to colliide with Anything in front of it.
I set this capsule to be visible and it visibly overlaps walls, like it doesnt have any collision.
It is not only the wall, it also overlaps other player’s head when I stand close.

I would like to know how do game developers usually deal with these kind of issues. I don’t think the method I am going with is the smartest.

Whats the physics setup on the cubes?

I suspect a mismatch between the collision preset on the capsule on the gun and the one in the world

I didn’t understand the documentation quite well. Here are my new screenshots:

  1. Weapon Collision …

2.Weapon that is going to be in my hands … when i pick it up !

3.Cube setup.

Can you help me choose what to check here?

These cube options and weapon options were found inside UE documentation.
Cube is, with these options, just like a trigger(you can go through it), and I set everything again to BLOCK ALL so its like a real block but i still have my weapon overlaping it…

try going over this one. Collision | Unreal Engine Documentation
oh wait a sec, what about collision in the player character after you “pickup” the gun thats a different set of physics options again.

Ok, I will remove collision from Pistol completely. I want that second capsule, on screenshot at the top of the page, to have collision… When it touches wall it just stops character.
-I was trying to use OnOverlap and OnEndOverlap event and It worked, but when i come slowly close to the cube it stops character but if i run into cube then my weapon goes through wall again :stuck_out_tongue:
So now we only need to focus on that second capsule in Viewport.

Thanks for your help!

Level blueprint for picking up a weapon.

Is there a way to set collision with Blueprint when i pick up weapon ?

unfortunately the overlap events aren’t blocking, unless you called an action to then block based on its output.
i would recommend shrinking it, and taking it outside of the main palyer collision capsule to avoid colliding with the player. then you can at least test the other modes. but you may not be able to use the collision presets, and might have to go through the tick boxes of blocking/overlap on the guns capsule to find the right one.
there are only 6 to choose from, and only 4 that would be used in this case. worldstatic/dynamic/pawn/physicsbody

and try turning off “generate overlap events” if its turned on.
sorry my answer may be a little fuzzy.

you would need to do a get of the capsule and then set its collision state
you can use “Get Capsule”, then “set collision” on the output.

I have been trying to make this work the whole day, still got nothing…
This is what i did :

  1. I opened project settings, created new object channel called “PlyrCapsule”.
  2. In Player BP in viewport i set second capsule’s object type to “PlyrCapsule”.
  3. Then in Cube’s Collision i set Custom collision to block “PlyrCapsule”.
  4. My weapon still overlaps the wall.

Once again: I removed collision from my weapon.I put capsule further from me as you said, for avoiding colliding with player(even if I could set overlap properties in collision). And this is going to be simple Multiplayer Game. For that reason, I can’t shrink my weapon. Maybe I could make the weapon shrunk for individual players, but for other players the weapon would look normally sized. Though, other players would see the weapon overlaping from another player (which is tha main reason I want to fix this, as it can be used to “cheat” by seeing someone else’s gun peaking through wall)

Here are my screenshots:

Thanks :slight_smile:

You know your capsules not set to simulate physics right?

I got around this issue by attaching a spring arm to the first person mesh so that it moves back when you get near walls. Collision is limited to just the capsule for all characters so the only real way to do what you’re trying to accomplish is to edit the source code for the character BP or create your own pawn from scratch.