The CapsuleComponent is not smooth on stairs, How to fix it?
p.s. The stairs is a example, It can happen on a hillside, on a rock, in any uneven place
-1-
You can create an invisible ramp on the stairs so that the physical player can smoothly climb there. Though after you implement this, you will see the player floating in between the stairs. To prevent that, you can implement IK legs to the player using control rigs.
Important Note: Your mesh must have a root component in order for that to work, the default character that the engine provides will cause no issue on that but keep that in mind in the future while you’re trying to implement the same thing to your custom models.
For the line traces which will be used in the IK legs logic to detect only the stairs and not the invisible ramp, you can create a custom trace channel that excludes that invisible ramp.
-2-
I was doing something completely irrelevant and I randomly got another idea! You can also set the “Max Step Height” setting of the player to 0 and manage the stepping mechanism yourself. To do that, you can have a line trace frequently being casted from the player’s center bottom to the outer edge of the collision capsule, and it’s direction should be the same as the direction of movement input. Then have another line trace to be frequently casted with the exact same logic, just it’s height should be above the ground unlike the previous one, how high you desire your custom max step height to be. Now when the bottom one hits something while the other doesn’t, that means that there’s elevation. Though we still don’t know if that elevation is a stair or a ramp, so to clear that up, we can cast another frequent line trace from the end point of the upper line trace straight to the ground. If that one’s hit location isn’t the end point of the bottom line trace (which you can detect by using relative location to the player) that means it’s a ramp and not a stair and we don’t need the player to do anything extra in that case. However if it’s a stair and there’s also input, you can play a stair climbing animation, or if you have stairs with different heights in your world, you can also implement that IK leg in this approach as well.
Oh almost forgot, and besides the animation, you should also handle that physical elevation while climbing stairs yourself in this solution which was actually the whole point of this disabling the auto one and replacing it with a smooth one. That’s pretty straightforward so I think it doesn’t need further explanation, just transformation.
Difference:
What’s the difference between these two methods? In the first one you can still bump into that invisible ramp when you get thrown into that direction or flying by, but in the second one there’s no such problem. I’ll be damned if I’m overcomplicating it but I managed to come up with these, hope they help!
All you really need to do, instead of even reading the above, is to correctly set the Step Height value on the character movement component.
Not that the above is complete nonsense. He does have some fair points if you want to delve into it.