From c944e5e6f93abd59f838f3b44f168906ef66e94f Mon Sep 17 00:00:00 2001 From: baz Date: Mon, 18 Sep 2023 02:29:49 +0100 Subject: [PATCH] Add extra checking to Expand Crosshair functionality --- Source/Nakatomi/PlayerHUDWidget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Nakatomi/PlayerHUDWidget.cpp b/Source/Nakatomi/PlayerHUDWidget.cpp index bf73bbc..e19c4ba 100644 --- a/Source/Nakatomi/PlayerHUDWidget.cpp +++ b/Source/Nakatomi/PlayerHUDWidget.cpp @@ -20,10 +20,12 @@ void UPlayerHUDWidget::ExpandCrosshair() { if (CrosshairFired) { - auto player = Cast(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)); - float playbackSpeed = 1.0 / player->GetCurrentWeapon()->GetWeaponProperties()->WeaponCooldown; + if (auto player = Cast(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); + } } }