69 - Fire Weapon Effects

This commit is contained in:
Kingsmedia 2022-05-04 22:27:26 +02:00
parent 99275f1b71
commit cd21cd9366
5 changed files with 13 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@ -58,9 +58,11 @@ void UCombatComponent::OnRep_EquippedWeapon()
void UCombatComponent::FireButtonPressed(bool bPressed)
{
bFireButtonPressed = bPressed;
if (EquippedWeapon == nullptr) return;
if (Character && bFireButtonPressed)
{
Character->PlayFireMontage(bAiming);
EquippedWeapon->Fire();
}
}

View File

@ -109,3 +109,11 @@ void AWeapon::ShowPickupWidget(bool bShowWidget)
PickupWidget->SetVisibility(bShowWidget);
}
}
void AWeapon::Fire()
{
if (FireAnimation)
{
WeaponMesh->PlayAnimation(FireAnimation, false);
}
}

View File

@ -25,6 +25,7 @@ public:
AWeapon();
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
void ShowPickupWidget(bool bShowWidget);
void Fire();
protected:
virtual void BeginPlay() override;
@ -63,6 +64,8 @@ private:
UPROPERTY(VisibleAnywhere, Category="Weapon Properties")
class UWidgetComponent* PickupWidget;
UPROPERTY(EditAnywhere, Category= "Weapon Properties")
class UAnimationAsset* FireAnimation;
public:
void SetWeaponState(EWeaponState State);
FORCEINLINE USphereComponent* GetAreaSphere() const { return AreaSphere; }