Add extra checking to Expand Crosshair functionality

This commit is contained in:
baz 2023-09-18 02:29:49 +01:00
parent 9ece07b011
commit c944e5e6f9
1 changed files with 5 additions and 3 deletions

View File

@ -20,10 +20,12 @@ void UPlayerHUDWidget::ExpandCrosshair()
{
if (CrosshairFired)
{
auto player = Cast<APlayerCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
float playbackSpeed = 1.0 / player->GetCurrentWeapon()->GetWeaponProperties()->WeaponCooldown;
if (auto player = Cast<APlayerCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)))
{
float playbackSpeed = 1.0 / player->GetCurrentWeapon()->GetWeaponProperties()->WeaponCooldown;
PlayAnimation(CrosshairFired, 0.0f, 1, EUMGSequencePlayMode::Forward, playbackSpeed);
PlayAnimation(CrosshairFired, 0.0f, 1, EUMGSequencePlayMode::Forward, playbackSpeed);
}
}
}