// fAlpha は FMath::InterpEaseInOut(0.0f, 1.0f, fAlpha, fExp); などで補間
void AThirdPersonCppCharacter::Rot2Target(const FVector& vTarget, float fAlpha)
{
// Zをゼロにする
FVector vPos = GetActorLocation();
FVector vFwd = GetActorForwardVector();
vFwd.Z = 0.0f;
vFwd.Normalize();
FQuat qFwd(vFwd.Rotation());
FVector vDir = vTarget - vPos;
vDir.Z = 0.0f;
vDir.Normalize();
FQuat qTarget(vDir.Rotation());
FQuat qResult = FQuat::Slerp(qFwd, qTarget, fAlpha);
SetActorRotation(qResult);
}
|