C++ WorldVector transform to LocaVector

Hi,
im trying to create a drone in UE4 C++
i AddTorqueInRadians to my motors, but Torque is added in World transform, so even if my drone is tilted, it still spins on world X axis only, how do i convert below to local Vector?


FVector vector_LB_Yaw = (FVector(0, 0, (ThrottleV - YawV) * YawPower));
Motor_LB->AddTorqueInRadians(vector_LB_Yaw, Motor_LB->GetFName());


BONUS:
Anyone has any suggestion on how to implement PID properly?

Thanks



const FRotator MotorRotation = /* Your Motor's world rotation */;
const FVector YawTorqueWS = FVector(0.f, 0.f, (ThrottleV - YawV) * YawPower)); /* The Yaw Torque we want to apply in World Space */
const FVector YawTorqueLS = FRotationMatrix(MotorRotation).TransformVector(YawTorqueWS); /* Transform World Space Torque by the component's World Rotation to Local */
Motor_LB->AddTorqueInRadians(YawTorqueLS, Motor_LB->GetFName());