How to get the capsule collision component fit with the animation (like sitting)?

When I played the sit/lie down animation, the capsule component was still upright, which made the character attacking the air and causing the opponent to take damage. I tried to rotate the capsule component by C++, but it didn’t work. I also thought about adding a new collision component for dealing with damage and the original capsule component for dealing with physics, but if the character crawls it won’t handle collisions correctly(capsule too large). Any ideas? Thanks!