So recently I came up with a very simple idea that I don’t know how to implement, so I came here for some help. I am working on an FPS game and I’m trying to make my weapon not go through walls. I managed to ‘‘fix’’ this by moving my character back and not letting the weapon stick out of the collision capsule (I’m using the third person character in first-person view), but this creates another problem: the camera can go through walls sometimes, for example when looking up near a wall, because it goes out of the collision capsule.
I could ‘‘fix’’ this by setting a lower view pitch max for the follow camera but it doesn’t look good.
My idea is the following: I want to leave the character in its back position, so the weapon doesn’t stick out of the collision capsule and it never goes through walls, but make it so that when the player looks up, the character and the follow camera move forward, eliminating the possibility of the follow camera going through walls because it will always remain inside the collision capsule.
Any help is appreciated
Camera Boom is used to mitigate TPP cams from clipping.
Here’s a vid that shows this: How To Stop Camera Clipping Through Walls /Objects - Unreal Engine 4 Tutorial - YouTube
You could also go the route of adding a sphere collision to the camera and dynamically adjust its position on begin/end overlap.
For weapon clipping you’ll probably want to eventually go with Inverse Kinematics.
Mushing everything into the capsule component …Scaling up the capsule component will cause other issues down the line.
After some tests I managed to have something like this working, it probably isn’t the most efficient but it works!
I created a function inside my third person character that I connected to the tick event.
It’s a very simple setup, it sets the value of a float variable using the rotation of the follow camera and then uses that to set the location of the mesh. The location changes in small steps so it isn’t noticeable.
And that’s it, the weapon never goes through the walls and neither does the camera. Hope this helps someone
Please don’t ever use any Epic service to host images.