Check out how Advanced Locomotion System V4 does it in the anim blueprint, it’s free on the marketplace. I believe this is done by sampling an animation for the character rotating head and torso left to right. You can simply retarget to this animation and integrate it into your anim BP or retarget the whole animation blueprint as is and integrate your code into it.