AimOffset Function for Yaw
if (speed == 0.f && !bIsInAir)//standing not juumping
{
FRotator currentAimRotation = FRotator(0.f, GetBaseAimRotation().Yaw, 0.f);
FRotator deltaAimRotation = UKismetMathLibrary::NormalizedDeltaRotator(currentAimRotation, StartingAimRotation);
AO_Yaw = deltaAimRotation.Yaw;
if (TurnInPlace == ETurnInPlace::ETIP_NotTurning)
{
InterpAO_Yaw = AO_Yaw;
}
bUseControllerRotationYaw = true;
TurnInPlaceFun(DeltaTime);
}
if (speed > 0.f || bIsInAir) // running or jumping
{
StartingAimRotation = FRotator(0.f, GetBaseAimRotation().Yaw, 0.f);
AO_Yaw = 0.f;
bUseControllerRotationYaw = true;
TurnInPlace = ETurnInPlace::ETIP_NotTurning;
}
Turn in Place -
if (AO_Yaw > 90.f)
{
TurnInPlace = ETurnInPlace::ETIP_Right;
}
else if (AO_Yaw < -90.f)
{
TurnInPlace = ETurnInPlace::ETIP_Left;
}
if (TurnInPlace != ETurnInPlace::ETIP_NotTurning)
{
InterpAO_Yaw = FMath::FInterpTo(InterpAO_Yaw, 0.f, DeltaTime, 4.f);
AO_Yaw = InterpAO_Yaw;
if (FMath::Abs(AO_Yaw) < 15.f)
{
TurnInPlace = ETurnInPlace::ETIP_NotTurning;
StartingAimRotation = FRotator(0.f, GetBaseAimRotation().Yaw, 0.f);
}
AnimInstance - for Yaw
//Offset yaw for strafing
FRotator AimRotation = MyCharacter->GetBaseAimRotation();
//UE_LOG(LogTemp, Warning, TEXT("AimRotationYaw: %f"), AimRotation.Yaw);
FRotator MovementRotation = UKismetMathLibrary::MakeRotFromX(MyCharacter->GetVelocity());
//UE_LOG(LogTemp, Warning, TEXT("MovementRotationYaw: %f"), MovementRotation.Yaw);
//Fix the Glitch animation of swtiching from -180 and 180 in BlendSpace
FRotator DeltaRot = UKismetMathLibrary::NormalizedDeltaRotator(MovementRotation, AimRotation);
DeltaRotation = FMath::RInterpTo(DeltaRotation, DeltaRot, DeltaSeconds, 6.0f);
YawOffset = DeltaRotation.Yaw;
Please I need help in this.

