Add Hitmarker HUD asset, animation and Enemy Hit Delegate
This commit is contained in:
parent
1fb9930791
commit
2a33897198
BIN
Content/UI/WidgetHUD.uasset (Stored with Git LFS)
BIN
Content/UI/WidgetHUD.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -342,6 +342,8 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits)
|
|||
{
|
||||
healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr,
|
||||
GetController(), this);
|
||||
|
||||
OnEnemyHit.ExecuteIfBound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
class UInputAction;
|
||||
class UInputMappingContext;
|
||||
|
||||
DECLARE_DELEGATE(FOnEnemyHitDelegate)
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -61,6 +63,8 @@ public:
|
|||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TSubclassOf<class UUserWidget> PlayerHUD;
|
||||
|
||||
FOnEnemyHitDelegate OnEnemyHit;
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
float SprintSpeedMultiplier = 2.0f;
|
||||
|
|
|
@ -12,6 +12,7 @@ void UPlayerHUDWidget::NativeConstruct()
|
|||
if (player)
|
||||
{
|
||||
player->OnFired.BindUFunction(this, "ExpandCrosshair");
|
||||
player->OnEnemyHit.BindUFunction(this, "ShowHitMarker");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,3 +26,11 @@ void UPlayerHUDWidget::ExpandCrosshair()
|
|||
PlayAnimation(CrosshairFired, 0.0f, 1, EUMGSequencePlayMode::Forward, playbackSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
void UPlayerHUDWidget::ShowHitMarker()
|
||||
{
|
||||
if (RevealHitmarker)
|
||||
{
|
||||
PlayAnimation(RevealHitmarker, 0.0f, 1, EUMGSequencePlayMode::Forward, 1.0f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@ public:
|
|||
UFUNCTION()
|
||||
void ExpandCrosshair();
|
||||
|
||||
UFUNCTION()
|
||||
void ShowHitMarker();
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
UTextBlock* HealthText;
|
||||
|
||||
|
@ -47,6 +50,12 @@ public:
|
|||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
UImage* CrosshairImage;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
UImage* HitmarkerImage;
|
||||
|
||||
UPROPERTY(Transient, meta = (BindWidgetAnim))
|
||||
UWidgetAnimation* CrosshairFired;
|
||||
|
||||
UPROPERTY(Transient, meta = (BindWidgetAnim))
|
||||
UWidgetAnimation* RevealHitmarker;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue