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 = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Attached Grenade"));
|
||||||
AttachedGrenade->SetupAttachment(GetMesh(), FName("RightHandThrowableSocket"));
|
AttachedGrenade->SetupAttachment(GetMesh(), FName("RightHandThrowableSocket"));
|
||||||
AttachedGrenade->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
AttachedGrenade->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ABlasterCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
void ABlasterCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||||
|
@ -184,6 +183,10 @@ void ABlasterCharacter::BeginPlay()
|
||||||
{
|
{
|
||||||
OnTakeAnyDamage.AddDynamic(this, &ABlasterCharacter::ReceiveDamage);
|
OnTakeAnyDamage.AddDynamic(this, &ABlasterCharacter::ReceiveDamage);
|
||||||
}
|
}
|
||||||
|
if (AttachedGrenade)
|
||||||
|
{
|
||||||
|
AttachedGrenade->SetVisibility(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ABlasterCharacter::Tick(float DeltaTime)
|
void ABlasterCharacter::Tick(float DeltaTime)
|
||||||
|
|
|
@ -208,4 +208,5 @@ public:
|
||||||
FORCEINLINE UCombatComponent* GetCombat() const { return Combat; }
|
FORCEINLINE UCombatComponent* GetCombat() const { return Combat; }
|
||||||
FORCEINLINE bool GetDisableGameplay() const { return bDisableGameplay; }
|
FORCEINLINE bool GetDisableGameplay() const { return bDisableGameplay; }
|
||||||
FORCEINLINE UAnimMontage* GetReloadMontage() const { return ReloadMontage; }
|
FORCEINLINE UAnimMontage* GetReloadMontage() const { return ReloadMontage; }
|
||||||
|
FORCEINLINE UStaticMeshComponent* GetAttachedGrenade() const { return AttachedGrenade; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -312,6 +312,11 @@ void UCombatComponent::ThrowGrenadeFinished()
|
||||||
AttachActorToRightHand(EquippedWeapon);
|
AttachActorToRightHand(EquippedWeapon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UCombatComponent::LaunchGrenade()
|
||||||
|
{
|
||||||
|
ShowAttachedGrenade(false);
|
||||||
|
}
|
||||||
|
|
||||||
void UCombatComponent::OnRep_CombatState()
|
void UCombatComponent::OnRep_CombatState()
|
||||||
{
|
{
|
||||||
switch (CombatState)
|
switch (CombatState)
|
||||||
|
@ -330,6 +335,7 @@ void UCombatComponent::OnRep_CombatState()
|
||||||
{
|
{
|
||||||
Character->PlayThrowGrenadeMontage();
|
Character->PlayThrowGrenadeMontage();
|
||||||
AttachActorToLeftHand(EquippedWeapon);
|
AttachActorToLeftHand(EquippedWeapon);
|
||||||
|
ShowAttachedGrenade(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -362,6 +368,7 @@ void UCombatComponent::ThrowGrenade()
|
||||||
{
|
{
|
||||||
Character->PlayThrowGrenadeMontage();
|
Character->PlayThrowGrenadeMontage();
|
||||||
AttachActorToLeftHand(EquippedWeapon);
|
AttachActorToLeftHand(EquippedWeapon);
|
||||||
|
ShowAttachedGrenade(true);
|
||||||
}
|
}
|
||||||
if (Character && !Character->HasAuthority())
|
if (Character && !Character->HasAuthority())
|
||||||
{
|
{
|
||||||
|
@ -376,6 +383,15 @@ void UCombatComponent::ServerThrowGrenade_Implementation()
|
||||||
{
|
{
|
||||||
Character->PlayThrowGrenadeMontage();
|
Character->PlayThrowGrenadeMontage();
|
||||||
AttachActorToLeftHand(EquippedWeapon);
|
AttachActorToLeftHand(EquippedWeapon);
|
||||||
|
ShowAttachedGrenade(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UCombatComponent::ShowAttachedGrenade(bool bShowGrenade)
|
||||||
|
{
|
||||||
|
if (Character && Character->GetAttachedGrenade())
|
||||||
|
{
|
||||||
|
Character->GetAttachedGrenade()->SetVisibility(bShowGrenade);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,9 @@ public:
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void ThrowGrenadeFinished();
|
void ThrowGrenadeFinished();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void LaunchGrenade();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
void SetAiming(bool bIsAiming);
|
void SetAiming(bool bIsAiming);
|
||||||
|
@ -74,6 +77,7 @@ protected:
|
||||||
void UpdateCarriedAmmo();
|
void UpdateCarriedAmmo();
|
||||||
void PlayEquipWeaponSound();
|
void PlayEquipWeaponSound();
|
||||||
void ReloadEmptyWeapon();
|
void ReloadEmptyWeapon();
|
||||||
|
void ShowAttachedGrenade(bool bShowGrenade);
|
||||||
private:
|
private:
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
class ABlasterCharacter* Character;
|
class ABlasterCharacter* Character;
|
||||||
|
|
Loading…
Reference in New Issue