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,
|
healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr,
|
||||||
GetController(), this);
|
GetController(), this);
|
||||||
|
|
||||||
|
OnEnemyHit.ExecuteIfBound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
class UInputAction;
|
class UInputAction;
|
||||||
class UInputMappingContext;
|
class UInputMappingContext;
|
||||||
|
|
||||||
|
DECLARE_DELEGATE(FOnEnemyHitDelegate)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -61,6 +63,8 @@ public:
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
TSubclassOf<class UUserWidget> PlayerHUD;
|
TSubclassOf<class UUserWidget> PlayerHUD;
|
||||||
|
|
||||||
|
FOnEnemyHitDelegate OnEnemyHit;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
float SprintSpeedMultiplier = 2.0f;
|
float SprintSpeedMultiplier = 2.0f;
|
||||||
|
|
|
@ -12,6 +12,7 @@ void UPlayerHUDWidget::NativeConstruct()
|
||||||
if (player)
|
if (player)
|
||||||
{
|
{
|
||||||
player->OnFired.BindUFunction(this, "ExpandCrosshair");
|
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);
|
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()
|
UFUNCTION()
|
||||||
void ExpandCrosshair();
|
void ExpandCrosshair();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void ShowHitMarker();
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||||
UTextBlock* HealthText;
|
UTextBlock* HealthText;
|
||||||
|
|
||||||
|
@ -47,6 +50,12 @@ public:
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||||
UImage* CrosshairImage;
|
UImage* CrosshairImage;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||||
|
UImage* HitmarkerImage;
|
||||||
|
|
||||||
UPROPERTY(Transient, meta = (BindWidgetAnim))
|
UPROPERTY(Transient, meta = (BindWidgetAnim))
|
||||||
UWidgetAnimation* CrosshairFired;
|
UWidgetAnimation* CrosshairFired;
|
||||||
|
|
||||||
|
UPROPERTY(Transient, meta = (BindWidgetAnim))
|
||||||
|
UWidgetAnimation* RevealHitmarker;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue