Mesh completely distorted when assigning animation

The rest pose of your mesh should be close to the A pose of the UE4 mannequin. All bones below pelvis (and the “IK” bones) should be switched from animation to skeleton in the retargetting options then it usually works well.