diff --git a/Content/Blueprints/Weapon/BP_AssaultRifle.uasset b/Content/Blueprints/Weapon/BP_AssaultRifle.uasset new file mode 100644 index 0000000..a76ea7f Binary files /dev/null and b/Content/Blueprints/Weapon/BP_AssaultRifle.uasset differ diff --git a/Content/Maps/BlasterMap.umap b/Content/Maps/BlasterMap.umap index cb63dfe..2ca2a95 100644 Binary files a/Content/Maps/BlasterMap.umap and b/Content/Maps/BlasterMap.umap differ diff --git a/Source/Blaster/Components/CombatComponent.cpp b/Source/Blaster/Components/CombatComponent.cpp index 31abfc0..ca36c81 100644 --- a/Source/Blaster/Components/CombatComponent.cpp +++ b/Source/Blaster/Components/CombatComponent.cpp @@ -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(); } } diff --git a/Source/Blaster/Weapon/Weapon.cpp b/Source/Blaster/Weapon/Weapon.cpp index 5f67027..1c5f654 100644 --- a/Source/Blaster/Weapon/Weapon.cpp +++ b/Source/Blaster/Weapon/Weapon.cpp @@ -109,3 +109,11 @@ void AWeapon::ShowPickupWidget(bool bShowWidget) PickupWidget->SetVisibility(bShowWidget); } } + +void AWeapon::Fire() +{ + if (FireAnimation) + { + WeaponMesh->PlayAnimation(FireAnimation, false); + } +} diff --git a/Source/Blaster/Weapon/Weapon.h b/Source/Blaster/Weapon/Weapon.h index 2f0b244..ba0bb6c 100644 --- a/Source/Blaster/Weapon/Weapon.h +++ b/Source/Blaster/Weapon/Weapon.h @@ -25,6 +25,7 @@ public: AWeapon(); virtual void GetLifetimeReplicatedProps(TArray& 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; }