Hi everyone, I have a simple crouch system running on a flip flop triggered by my Left Shift key.
Problem is, whenever i crouch, my character will clip into the floor, but will not fall through. What’s more is that my camera will not follow my character’s head, but instead will instantly snap to my desired position. The crouching animation will play, however, and the crouch functionality itself works. My issues here are entirely visual. I’ve made a couple posts about this before but I’ve gotten no answers.
I’m still pretty new to UE, so I’ll try to answer any questions as best I can.
Below is a video of my issue. Help is greatly appreciated.
How are you crouching; are you using unreals built in crouch functions, or your own implementation?
this could be why the anims are clipping if you are using your own implementation, if not then I assume there’s an issue with the root of the anim.
With your camera issue; I once again assume you have a camera attached to maybe a spring arm or to your player capsule. If you use unreals built in crouching, i’m pretty sure it just cuts your capsule in half, or scales it down by half which is why you see the jumping when you switch between because it instantly changes the value rather than lerping it. Try adding the spring arm/camera to your mesh (add it to your neck socket or something) instead of your capsule and it should move at the same speed as your anim.
i think you’d need to adjust the mesh offset when crouching.
by defaults its -90 on the z (from memory) because the capsule is approx 180 in height (so effectively the middle) when you crouch the capsule height changed so the mesh offset also needs to change
where the mesh is attached in the viewport, you can adjust it manually with Mesh->SetRelativeLocation
as an example (im not in editor)
you’d want to lerp it to be smooth but for testing on crouch set relative location to something like (0,0,-50) and on uncrouch back to (0,0,-90)
same result as in snapping or same result as in still phasing into the floor?
to fix the snapping you do want to lerp it but you lerp correctly you need a timeline.
probably best to just watch a video on lerping if you’re not sure
if its still in the floor try adjusting the Z value i was just guessing before
Sadly the built in Crouch function for the Character Movement Component is very limited, and the best way to circumvent a lot of the problems you are facing is to create your own system for it.
The Character Controller doesn’t support any kind of blending when crouching, which is why your camera is snapping.
A simple way to accomplish this is to adjust the capsule half height using something like a Timeline.
Similarly, the foot position of the character needs to blend upwards in the Z axis too (Using the same timeline will suffice)
I built a custom character to get around issues like this for my projects.
(You can probably ignore a lot of the extra nodes, as my character supports a lot of addition states that you may not need)
I decided to start a new project and follow a crouching tutorial on both projects to see if I could spot any differences. Turns out, I was using an entirely wrong third-person character mesh which wasn’t supposed to exist, which was causing my character to phase through the floor. How stupid of me.