Incorrect Character Collision While Crouching

Hey!

So I finally got to making crouching animations and functionality and now I am pleased with how it works… apart from the collision. I tried searching online on how to do this but 99% of the topics were about “how do I make my collision capsule shorter (crouched half height)”. I don’t mean that.

In this picture you can see my problem:
Crouched_Collision_Problem

So the collision capsule is okay when the character is in any other stance, but when it’s crouched it is in the completely wrong place/orientation. Is there a way to rotate/change the collision (without making the collision capsule 30 miles wide) so that it would work better in this stance? :thinking:

Okay so this kinda does what I want it to do:

But, is there a less janky way of doing it since rotating the collision capsule and the mesh makes the camera and everything else go apeshit when you crouch?

EDIT: Also the socket rotations are wrong and if you walk into anything while the collision capsule is rotated like that, it makes it snap back to upright and then the character mesh is permanently at a 45 degree angle.

The character movement component only works with vertically oriented capsules, rotating the capsule will introduce all sorts of problems. Why don’t you just increase the capsule radius when crouched? It will enclose the mesh much more accurately.

1 Like

I actually did that now in addition to moving the capsule component forward a bit so it surrounds the character better (no rotation). It still has the issue that on the sides of the character the hitbox is so much bigger than it should be. Could there be some way to fix that? :thinking: Oh how I wish you could edit the capsule size in three directions instead of two…

Also the character’s head sticks kinda outside of the collision and enclosing it inside the collision capsule would make it even bigger, adding to the problem. The shape of the capsule just doesn’t work well with the feet and the head, how did they not foresee this as a problem when they already have the crouching element in UE by default?

The reason you can’t just form the collision any way you want is performance. A capsule is a relatively simple shape allowing for cheaper collision calculations as well as being a good approximation for humanoid characters and providing useful hit normals for most scenarious (unlike a box collision for example). In theory you could make a movement component that allows arbitrary rotations of the capsule but that would make the movement code much more complex and is usually not worth the trouble. A lot of games with a humanoid character use an unrotated vertical capsule for collision and most of them have the problem that (depending on the animation) parts of the body often clip through walls and such because the mesh peeks out of the collision shape.