How can I get the same effect as this function in c++?
Thanks,
Sammy
How can I get the same effect as this function in c++?
Thanks,
Sammy
You can just use the + or += operators.
RotatorA + RotatorB = RotatorC; // A + B, the new result is stored in C.
RotatorA += RotatorB; // A + B, the new result is stored in A.
Nice and easy, thank you very much.
The function is actually implemented with quaternions so you might get different results to simply adding together rotators in some cases.
Actual code:
FRotator UKismetMathLibrary::ComposeRotators(FRotator A, FRotator B)
{
FQuat AQuat = FQuat(A);
FQuat BQuat = FQuat(B);
return FRotator(BQuat*AQuat);
}
thanks.
also possible to write it in one line if somebody needs to:
return FRotator(FQuat(A)*FQuat(B));
Just for the records and in case someone finds this suggestion and gets strange results, the product (composition) of quaternions is non-commutative, so it should be:
return FRotator(FQuat(B)*FQuat(A))
as order matters.