I use the 3rd person template on witch I added a free camera mode that activate and deactivate on the press and the release of a button. I added the 2 fallowing function in my character class to do so.
void AATPreProtoCharacter::CameraOnly()
{
bUseControllerRotationYaw = false;
}
void AATPreProtoCharacter::StopCameraOnly()
{
bUseControllerRotationYaw = true;
}
It work great, except for one little detail, when the button is release the character immediately rotate to where the camera is pointing. But what i want is the opposite, the camera to rotate back to where the character is pointing.
After some search on the forum I came with the fallowing solution (point the camera back to the character rotation with the AddControllerYawInput function), but can’t figure out how to make it work (how to calculate the float from the character and the camera rotation), all it dose is rotating the character and the camera in a “random” rotation.
void AATPreProtoCharacter::StopCameraOnly()
{
if (Controller != NULL)
{
const FRotator CameraRotation = CameraBoom->GetComponentRotation();
const FRotator ActorRotation = GetActorRotation();
/*
const FRotator TempRotation(0.f, 90.0f, 0.f);
FQuat AQuat = FQuat(ActorRotation);
FQuat BQuat = FQuat(TempRotation);
const FRotator NewRotation(BQuat*AQuat);
*/
FRotator TargetRotation = ActorRotation - CameraRotation;
TargetRotation.Normalize();
AddControllerYawInput(TargetRotation.Yaw);
}
bUseControllerRotationYaw = true;
}
So can some one help me understand how to calculate this float parameter from rotation to point in the right direction? Or maybe I just use the wrong getter to have the right value to begin with?
P.S: Please any one, I’m kind of stock here, it’s my second post about this…