149 - Showing the Attached Grenade
This commit is contained in:
parent
2376723209
commit
d114ceb1fb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -59,7 +59,6 @@ ABlasterCharacter::ABlasterCharacter()
|
|||
AttachedGrenade = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Attached Grenade"));
|
||||
AttachedGrenade->SetupAttachment(GetMesh(), FName("RightHandThrowableSocket"));
|
||||
AttachedGrenade->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
|
||||
}
|
||||
|
||||
void ABlasterCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||
|
@ -184,6 +183,10 @@ void ABlasterCharacter::BeginPlay()
|
|||
{
|
||||
OnTakeAnyDamage.AddDynamic(this, &ABlasterCharacter::ReceiveDamage);
|
||||
}
|
||||
if (AttachedGrenade)
|
||||
{
|
||||
AttachedGrenade->SetVisibility(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterCharacter::Tick(float DeltaTime)
|
||||
|
|
|
@ -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; }
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue