create GE_DeathEffect
This commit is contained in:
@@ -21,4 +21,5 @@ NetIndexFirstBitSegment=16
|
|||||||
+GameplayTagList=(Tag="GameplayCue.cameraShake",DevComment="")
|
+GameplayTagList=(Tag="GameplayCue.cameraShake",DevComment="")
|
||||||
+GameplayTagList=(Tag="GameplayCue.hit.crunch.punch",DevComment="")
|
+GameplayTagList=(Tag="GameplayCue.hit.crunch.punch",DevComment="")
|
||||||
+GameplayTagList=(Tag="GameplayCue.hit.reaction",DevComment="")
|
+GameplayTagList=(Tag="GameplayCue.hit.reaction",DevComment="")
|
||||||
|
+GameplayTagList=(Tag="stats.dead",DevComment="")
|
||||||
|
|
||||||
|
|||||||
BIN
Content/GameplayAbilities/GameplayEffects/GE_Death.uasset
LFS
Normal file
BIN
Content/GameplayAbilities/GameplayEffects/GE_Death.uasset
LFS
Normal file
Binary file not shown.
Binary file not shown.
@@ -6,6 +6,7 @@
|
|||||||
#include "Components/WidgetComponent.h"
|
#include "Components/WidgetComponent.h"
|
||||||
#include "GAS/CAbilitySystemComponent.h"
|
#include "GAS/CAbilitySystemComponent.h"
|
||||||
#include "GAS/CAttributeSet.h"
|
#include "GAS/CAttributeSet.h"
|
||||||
|
#include "GAS/UCAbilitySystemStatics.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
#include "Widgets/OverHeadStatsGauge.h"
|
#include "Widgets/OverHeadStatsGauge.h"
|
||||||
|
|
||||||
@@ -29,6 +30,8 @@ ACCharacter::ACCharacter()
|
|||||||
**/
|
**/
|
||||||
OverHeadWidgetComponent = CreateDefaultSubobject<UWidgetComponent>("OverHead Widget Component");
|
OverHeadWidgetComponent = CreateDefaultSubobject<UWidgetComponent>("OverHead Widget Component");
|
||||||
OverHeadWidgetComponent->SetupAttachment(GetRootComponent());
|
OverHeadWidgetComponent->SetupAttachment(GetRootComponent());
|
||||||
|
|
||||||
|
BindGASChangeDelegate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACCharacter::ServerSideInit()
|
void ACCharacter::ServerSideInit()
|
||||||
@@ -67,6 +70,27 @@ UAbilitySystemComponent* ACCharacter::GetAbilitySystemComponent() const
|
|||||||
return CAbilitySystemComponent;
|
return CAbilitySystemComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACCharacter::DeadTagUpdated(FGameplayTag GameplayTag, int32 NewCount)
|
||||||
|
{
|
||||||
|
if (NewCount != 0)
|
||||||
|
{
|
||||||
|
StartDeathSequence();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ReSpawn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACCharacter::BindGASChangeDelegate()
|
||||||
|
{
|
||||||
|
if (CAbilitySystemComponent)
|
||||||
|
{
|
||||||
|
CAbilitySystemComponent->RegisterGameplayTagEvent(UCAbilitySystemStatics::GetDeadStatTag())
|
||||||
|
.AddUObject(this, &ThisClass::DeadTagUpdated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ACCharacter::ConfigureOverHeadStatusWidget()
|
void ACCharacter::ConfigureOverHeadStatusWidget()
|
||||||
{
|
{
|
||||||
if (!OverHeadWidgetComponent) return;
|
if (!OverHeadWidgetComponent) return;
|
||||||
@@ -100,3 +124,13 @@ void ACCharacter::UpdateHeadStatGaugeVisibility()
|
|||||||
OverHeadWidgetComponent->SetHiddenInGame(DistSquared > HeadStatGaugeVisibilityRangeSquared);
|
OverHeadWidgetComponent->SetHiddenInGame(DistSquared > HeadStatGaugeVisibilityRangeSquared);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACCharacter::StartDeathSequence()
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("----------------------------DEAD"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACCharacter::ReSpawn()
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("----------------------------Respawn"));
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,15 @@
|
|||||||
|
|
||||||
#include "GAS/CAbilitySystemComponent.h"
|
#include "GAS/CAbilitySystemComponent.h"
|
||||||
|
|
||||||
|
#include "GAS/CAttributeSet.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
UCAbilitySystemComponent::UCAbilitySystemComponent()
|
||||||
|
{
|
||||||
|
GetGameplayAttributeValueChangeDelegate(UCAttributeSet::GetHealthAttribute())
|
||||||
|
.AddUObject(this, &UCAbilitySystemComponent::HealthUpdated);
|
||||||
|
}
|
||||||
|
|
||||||
void UCAbilitySystemComponent::ApplyInitialEffects()
|
void UCAbilitySystemComponent::ApplyInitialEffects()
|
||||||
{
|
{
|
||||||
@@ -43,3 +52,13 @@ void UCAbilitySystemComponent::GiveInitialAbilities()
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UCAbilitySystemComponent::HealthUpdated(const FOnAttributeChangeData& ChangeData)
|
||||||
|
{
|
||||||
|
if (!GetOwner() && !GetOwner()->HasAuthority()) return;
|
||||||
|
if (ChangeData.NewValue <= 0 && DeathEffectClass)
|
||||||
|
{
|
||||||
|
const auto GameplayEffectSpecHandle{ MakeOutgoingSpec(DeathEffectClass, 1, MakeEffectContext() )};
|
||||||
|
ApplyGameplayEffectSpecToSelf(*GameplayEffectSpecHandle.Data.Get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,3 +7,8 @@ FGameplayTag UCAbilitySystemStatics::GetBasicAttackAbilityTag()
|
|||||||
{
|
{
|
||||||
return FGameplayTag::RequestGameplayTag("ability.basicattack");
|
return FGameplayTag::RequestGameplayTag("ability.basicattack");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FGameplayTag UCAbilitySystemStatics::GetDeadStatTag()
|
||||||
|
{
|
||||||
|
return FGameplayTag::RequestGameplayTag("stats.dead");
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "AbilitySystemInterface.h"
|
#include "AbilitySystemInterface.h"
|
||||||
|
#include "GameplayTagContainer.h"
|
||||||
#include "GameFramework/Character.h"
|
#include "GameFramework/Character.h"
|
||||||
#include "CCharacter.generated.h"
|
#include "CCharacter.generated.h"
|
||||||
|
|
||||||
@@ -34,6 +35,8 @@ public:
|
|||||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void DeadTagUpdated(FGameplayTag GameplayTag, int32 NewCount);
|
||||||
|
void BindGASChangeDelegate();
|
||||||
UPROPERTY(EditDefaultsOnly, Category="Gameplay Ability")
|
UPROPERTY(EditDefaultsOnly, Category="Gameplay Ability")
|
||||||
TObjectPtr<UCAbilitySystemComponent> CAbilitySystemComponent;
|
TObjectPtr<UCAbilitySystemComponent> CAbilitySystemComponent;
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
@@ -54,4 +57,10 @@ private:
|
|||||||
|
|
||||||
FTimerHandle HeadStatGaugeVisibilityUpdateTimerHandle;
|
FTimerHandle HeadStatGaugeVisibilityUpdateTimerHandle;
|
||||||
void UpdateHeadStatGaugeVisibility();
|
void UpdateHeadStatGaugeVisibility();
|
||||||
|
|
||||||
|
/********************************************************************************************/
|
||||||
|
/* Death & Respawning */
|
||||||
|
/********************************************************************************************/
|
||||||
|
void StartDeathSequence();
|
||||||
|
void ReSpawn();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "AbilitySystemComponent.h"
|
#include "AbilitySystemComponent.h"
|
||||||
|
#include "GameplayEffectTypes.h"
|
||||||
|
|
||||||
#include "CAbilitySystemComponent.generated.h"
|
#include "CAbilitySystemComponent.generated.h"
|
||||||
|
|
||||||
@@ -15,13 +16,18 @@ class CRUNCH_API UCAbilitySystemComponent : public UAbilitySystemComponent
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
UCAbilitySystemComponent();
|
||||||
void ApplyInitialEffects();
|
void ApplyInitialEffects();
|
||||||
void GiveInitialAbilities();
|
void GiveInitialAbilities();
|
||||||
|
void HealthUpdated(const FOnAttributeChangeData& ChangeData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPROPERTY(EditDefaultsOnly, Category="Gameplay Effects")
|
UPROPERTY(EditDefaultsOnly, Category="Gameplay Effects")
|
||||||
TArray<TSubclassOf<UGameplayEffect>> InitialEffects;
|
TArray<TSubclassOf<UGameplayEffect>> InitialEffects;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category="Gameplay Effects")
|
||||||
|
TSubclassOf<UGameplayEffect> DeathEffectClass;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, Category="Gameplay Ability")
|
UPROPERTY(EditDefaultsOnly, Category="Gameplay Ability")
|
||||||
TMap<ECAbilityInputID, TSubclassOf<UGameplayAbility>> Abilities;
|
TMap<ECAbilityInputID, TSubclassOf<UGameplayAbility>> Abilities;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class UCAbilitySystemStatics: public UObject
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
static FGameplayTag GetBasicAttackAbilityTag();
|
static FGameplayTag GetBasicAttackAbilityTag();
|
||||||
|
static FGameplayTag GetDeadStatTag();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user