Skip to content

Commit

Permalink
Add protection against NaN when calculating velocity blend amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
ameaninglessname authored and Sixze committed Jul 6, 2024
1 parent 3d22d20 commit aca0383
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Source/ALS/Private/AlsAnimationInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,15 @@ void UAlsAnimationInstance::RefreshVelocityBlend()

auto& VelocityBlend{GroundedState.VelocityBlend};

const auto RelativeVelocityDirection{GetRelativeVelocity().GetSafeNormal()};
auto RelativeVelocityDirection{GetRelativeVelocity()};
auto TargetVelocityBlend{FVector3f::ZeroVector};

const auto TargetVelocityBlend{
RelativeVelocityDirection /
(FMath::Abs(RelativeVelocityDirection.X) + FMath::Abs(RelativeVelocityDirection.Y) + FMath::Abs(RelativeVelocityDirection.Z))
};
if (RelativeVelocityDirection.Normalize())
{
TargetVelocityBlend =
RelativeVelocityDirection /
(FMath::Abs(RelativeVelocityDirection.X) + FMath::Abs(RelativeVelocityDirection.Y) + FMath::Abs(RelativeVelocityDirection.Z));
}

if (VelocityBlend.bInitializationRequired)
{
Expand Down

0 comments on commit aca0383

Please sign in to comment.