diff --git a/Content/Assets/Animations/GrenadeToss.uasset b/Content/Assets/Animations/GrenadeToss.uasset index cd68004..35b725e 100644 Binary files a/Content/Assets/Animations/GrenadeToss.uasset and b/Content/Assets/Animations/GrenadeToss.uasset differ diff --git a/Content/Assets/LearningKit_Games/Assets/Characters/Character/Mesh/SK_EpicCharacter_Skeleton.uasset b/Content/Assets/LearningKit_Games/Assets/Characters/Character/Mesh/SK_EpicCharacter_Skeleton.uasset index c8f1972..faada01 100644 Binary files a/Content/Assets/LearningKit_Games/Assets/Characters/Character/Mesh/SK_EpicCharacter_Skeleton.uasset and b/Content/Assets/LearningKit_Games/Assets/Characters/Character/Mesh/SK_EpicCharacter_Skeleton.uasset differ diff --git a/Content/Blueprints/Character/Animation/BlasterAnimBP.uasset b/Content/Blueprints/Character/Animation/BlasterAnimBP.uasset index 4e2d3db..fd821e2 100644 Binary files a/Content/Blueprints/Character/Animation/BlasterAnimBP.uasset and b/Content/Blueprints/Character/Animation/BlasterAnimBP.uasset differ diff --git a/Content/Blueprints/Character/BP_BlasterCharacter.uasset b/Content/Blueprints/Character/BP_BlasterCharacter.uasset index d64799d..a9124df 100644 Binary files a/Content/Blueprints/Character/BP_BlasterCharacter.uasset and b/Content/Blueprints/Character/BP_BlasterCharacter.uasset differ diff --git a/Source/Blaster/Character/BlasterCharacter.cpp b/Source/Blaster/Character/BlasterCharacter.cpp index 64363eb..63b1b16 100644 --- a/Source/Blaster/Character/BlasterCharacter.cpp +++ b/Source/Blaster/Character/BlasterCharacter.cpp @@ -59,7 +59,6 @@ ABlasterCharacter::ABlasterCharacter() AttachedGrenade = CreateDefaultSubobject(TEXT("Attached Grenade")); AttachedGrenade->SetupAttachment(GetMesh(), FName("RightHandThrowableSocket")); AttachedGrenade->SetCollisionEnabled(ECollisionEnabled::NoCollision); - } void ABlasterCharacter::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const @@ -184,6 +183,10 @@ void ABlasterCharacter::BeginPlay() { OnTakeAnyDamage.AddDynamic(this, &ABlasterCharacter::ReceiveDamage); } + if (AttachedGrenade) + { + AttachedGrenade->SetVisibility(false); + } } void ABlasterCharacter::Tick(float DeltaTime) diff --git a/Source/Blaster/Character/BlasterCharacter.h b/Source/Blaster/Character/BlasterCharacter.h index 928aa7c..100220e 100644 --- a/Source/Blaster/Character/BlasterCharacter.h +++ b/Source/Blaster/Character/BlasterCharacter.h @@ -208,4 +208,5 @@ public: FORCEINLINE UCombatComponent* GetCombat() const { return Combat; } FORCEINLINE bool GetDisableGameplay() const { return bDisableGameplay; } FORCEINLINE UAnimMontage* GetReloadMontage() const { return ReloadMontage; } + FORCEINLINE UStaticMeshComponent* GetAttachedGrenade() const { return AttachedGrenade; } }; diff --git a/Source/Blaster/Components/CombatComponent.cpp b/Source/Blaster/Components/CombatComponent.cpp index 8a94b83..c50e379 100644 --- a/Source/Blaster/Components/CombatComponent.cpp +++ b/Source/Blaster/Components/CombatComponent.cpp @@ -312,6 +312,11 @@ void UCombatComponent::ThrowGrenadeFinished() AttachActorToRightHand(EquippedWeapon); } +void UCombatComponent::LaunchGrenade() +{ + ShowAttachedGrenade(false); +} + void UCombatComponent::OnRep_CombatState() { switch (CombatState) @@ -330,6 +335,7 @@ void UCombatComponent::OnRep_CombatState() { Character->PlayThrowGrenadeMontage(); AttachActorToLeftHand(EquippedWeapon); + ShowAttachedGrenade(true); } break; } @@ -362,6 +368,7 @@ void UCombatComponent::ThrowGrenade() { Character->PlayThrowGrenadeMontage(); AttachActorToLeftHand(EquippedWeapon); + ShowAttachedGrenade(true); } if (Character && !Character->HasAuthority()) { @@ -376,6 +383,15 @@ void UCombatComponent::ServerThrowGrenade_Implementation() { Character->PlayThrowGrenadeMontage(); AttachActorToLeftHand(EquippedWeapon); + ShowAttachedGrenade(true); + } +} + +void UCombatComponent::ShowAttachedGrenade(bool bShowGrenade) +{ + if (Character && Character->GetAttachedGrenade()) + { + Character->GetAttachedGrenade()->SetVisibility(bShowGrenade); } } diff --git a/Source/Blaster/Components/CombatComponent.h b/Source/Blaster/Components/CombatComponent.h index bb246fe..359f54f 100644 --- a/Source/Blaster/Components/CombatComponent.h +++ b/Source/Blaster/Components/CombatComponent.h @@ -35,6 +35,9 @@ public: UFUNCTION(BlueprintCallable) void ThrowGrenadeFinished(); + + UFUNCTION(BlueprintCallable) + void LaunchGrenade(); protected: virtual void BeginPlay() override; @@ -74,6 +77,7 @@ protected: void UpdateCarriedAmmo(); void PlayEquipWeaponSound(); void ReloadEmptyWeapon(); + void ShowAttachedGrenade(bool bShowGrenade); private: UPROPERTY() class ABlasterCharacter* Character;