(4-27)
Hi;
I am trying to add a lean function to my c++ project, after calculating the YawDelta I want to displayed to my screen using the GEngine->AddOnScreenDebugMessage()
the problem it’s always 0 in the viewport screen when pressing play
here is my c++ code of the Lean function which is called in UpdateAnimationProperties (Tick)
void UShooterAnimInstance::Lean(float DeltaTime)
{
if (ShooterCharacter == nullptr) return;
CharacterYawLastFrame = CharacterYaw;
CharacterYaw = ShooterCharacter->GetActorRotation().Yaw;
const float Target{ (CharacterYaw - CharacterYawLastFrame) / DeltaTime };
const float Interp{ FMath::FInterpTo(YawDelta, Target, DeltaTime, 6.f) };
YawDelta = FMath::Clamp(Interp, -90.f, 90.f);
if (GEngine) GEngine->AddOnScreenDebugMessage(5,
-1,
FColor::Cyan,
FString::Printf(TEXT("YawDelta : %f"),
YawDelta));
}
PS: if I use UE_LOG, the output log shows the variable 2 times, one with the correct value and the other one is always 0
Please help