-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4. Unreal Engine 5 C++ | Gameplay Ability System - Step by Step
- Loading branch information
1 parent
0d044df
commit d3652b5
Showing
41 changed files
with
544 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
[/Script/EngineSettings.GeneralProjectSettings] | ||
ProjectID=03BD53194974379BBE6A46A88F4200BC | ||
CopyrightNotice=Fab by Kai Jurgeit | ||
|
||
[/Script/GameplayAbilities.AbilitySystemGlobals] | ||
bUseDebugTargetFromHud=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[/Script/GameplayTags.GameplayTagsSettings] | ||
ImportTagsFromConfig=True | ||
WarnOnInvalidTags=True | ||
ClearInvalidTags=False | ||
AllowEditorTagUnloading=True | ||
AllowGameTagUnloading=False | ||
FastReplication=False | ||
InvalidTagCharacters="\"\'," | ||
NumBitsForContainerSize=6 | ||
NetIndexFirstBitSegment=16 | ||
+GameplayTagList=(Tag="Event.Montage.Kick",DevComment="") | ||
+GameplayTagList=(Tag="Gameplay.Ability.Kick",DevComment="") | ||
+GameplayTagList=(Tag="Gameplay.Cooldown.Kick",DevComment="") | ||
+GameplayTagList=(Tag="Gameplay.Magnitude.Duration",DevComment="") | ||
+GameplayTagList=(Tag="Gameplay.State.IsKicking",DevComment="") | ||
+GameplayTagList=(Tag="GameplayCue.Kick",DevComment="") | ||
4 changes: 2 additions & 2 deletions
4
Content/Fab/Characters/Mannequins/Animations/ABP_Manny.uasset
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
Content/Fab/Characters/Player/Abilities/Kick/AM_HitReact.uasset
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
Content/Fab/Characters/Player/Abilities/Kick/ANS_Collider.uasset
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
Content/Fab/Characters/Player/Abilities/Kick/AS_HitReact.uasset
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
Content/Fab/Characters/Player/Abilities/Kick/A_CartoonPunch_05.uasset
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
Content/Fab/Characters/Player/Abilities/Kick/GC_Kick_Target.uasset
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
Content/Fab/Characters/Player/Abilities/Kick/GE_Kick_Cooldown.uasset
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
Content/Fab/Characters/Player/Abilities/Kick/GE_Kick_Costs.uasset
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
Content/Fab/Characters/Player/Abilities/Kick/GE_Recover_Health.uasset
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
Content/Fab/Characters/Player/Abilities/Kick/GE_Recover_Stamina.uasset
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
Content/Fab/Characters/Player/GE_PlayerDefaultAttributes.uasset
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,10 @@ | |
"TargetAllowList": [ | ||
"Editor" | ||
] | ||
}, | ||
{ | ||
"Name": "GameplayAbilities", | ||
"Enabled": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Fab by Kai Jurgeit | ||
|
||
|
||
#include "FabAbilitySystemComponent.h" | ||
|
||
|
||
UFabAbilitySystemComponent::UFabAbilitySystemComponent() | ||
{ | ||
PrimaryComponentTick.bCanEverTick = true; | ||
SetIsReplicated(true); | ||
} | ||
|
||
void UFabAbilitySystemComponent::BeginPlay() | ||
{ | ||
Super::BeginPlay(); | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Fab by Kai Jurgeit | ||
|
||
#pragma once | ||
|
||
#include "CoreMinimal.h" | ||
#include "AbilitySystemComponent.h" | ||
#include "FabAbilitySystemComponent.generated.h" | ||
|
||
|
||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) | ||
class FAB_API UFabAbilitySystemComponent : public UAbilitySystemComponent | ||
{ | ||
GENERATED_BODY() | ||
|
||
public: | ||
UFabAbilitySystemComponent(); | ||
|
||
protected: | ||
virtual void BeginPlay() override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Fab by Kai Jurgeit | ||
|
||
|
||
#include "FabAttributeSet.h" | ||
#include "AbilitySystemComponent.h" | ||
#include "GameplayEffectExtension.h" | ||
#include "Net/UnrealNetwork.h" | ||
|
||
UFabAttributeSet::UFabAttributeSet() | ||
{ | ||
InitHealth(80.f); | ||
} | ||
|
||
void UFabAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const | ||
{ | ||
Super::GetLifetimeReplicatedProps(OutLifetimeProps); | ||
|
||
DOREPLIFETIME_CONDITION_NOTIFY(UFabAttributeSet, Health, COND_None, REPNOTIFY_Always); | ||
DOREPLIFETIME_CONDITION_NOTIFY(UFabAttributeSet, MaxHealth, COND_None, REPNOTIFY_Always); | ||
DOREPLIFETIME_CONDITION_NOTIFY(UFabAttributeSet, Stamina, COND_None, REPNOTIFY_Always); | ||
DOREPLIFETIME_CONDITION_NOTIFY(UFabAttributeSet, MaxStamina, COND_None, REPNOTIFY_Always); | ||
DOREPLIFETIME_CONDITION_NOTIFY(UFabAttributeSet, Strength, COND_None, REPNOTIFY_Always); | ||
DOREPLIFETIME_CONDITION_NOTIFY(UFabAttributeSet, MaxStrength, COND_None, REPNOTIFY_Always); | ||
} | ||
|
||
void UFabAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) | ||
{ | ||
Super::PreAttributeChange(Attribute, NewValue); | ||
|
||
if(Attribute == GetHealthAttribute()) | ||
{ | ||
NewValue = FMath::Clamp(NewValue, 0.f, GetMaxHealth()); | ||
} | ||
} | ||
|
||
void UFabAttributeSet::PostGameplayEffectExecute(const FGameplayEffectModCallbackData& Data) | ||
{ | ||
Super::PostGameplayEffectExecute(Data); | ||
|
||
if(Data.EvaluatedData.Attribute == GetHealthAttribute()) | ||
{ | ||
SetHealth(FMath::Clamp(GetHealth(), 0.f, GetMaxHealth())); | ||
} | ||
} | ||
|
||
void UFabAttributeSet::OnRep_Health(const FGameplayAttributeData& OldHealth) const | ||
{ | ||
GAMEPLAYATTRIBUTE_REPNOTIFY(UFabAttributeSet, Health, OldHealth); | ||
} | ||
|
||
void UFabAttributeSet::OnRep_MaxHealth(const FGameplayAttributeData& OldMaxHealth) const | ||
{ | ||
GAMEPLAYATTRIBUTE_REPNOTIFY(UFabAttributeSet, MaxHealth, OldMaxHealth); | ||
} | ||
|
||
void UFabAttributeSet::OnRep_Stamina(const FGameplayAttributeData& OldStamina) const | ||
{ | ||
GAMEPLAYATTRIBUTE_REPNOTIFY(UFabAttributeSet, Stamina, OldStamina); | ||
} | ||
|
||
void UFabAttributeSet::OnRep_MaxStamina(const FGameplayAttributeData& OldMaxStamina) const | ||
{ | ||
GAMEPLAYATTRIBUTE_REPNOTIFY(UFabAttributeSet, MaxStamina, OldMaxStamina); | ||
} | ||
|
||
void UFabAttributeSet::OnRep_Strength(const FGameplayAttributeData& OldStrength) const | ||
{ | ||
GAMEPLAYATTRIBUTE_REPNOTIFY(UFabAttributeSet, Strength, OldStrength); | ||
} | ||
|
||
void UFabAttributeSet::OnRep_MaxStrength(const FGameplayAttributeData& OldMaxStrength) const | ||
{ | ||
GAMEPLAYATTRIBUTE_REPNOTIFY(UFabAttributeSet, MaxStrength, OldMaxStrength); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Fab by Kai Jurgeit | ||
|
||
#pragma once | ||
|
||
#include "CoreMinimal.h" | ||
#include "AbilitySystemComponent.h" | ||
#include "AttributeSet.h" | ||
#include "FabAttributeSet.generated.h" | ||
|
||
#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \ | ||
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \ | ||
GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \ | ||
GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \ | ||
GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName) | ||
|
||
#define NUMERIC_VALUE(AttributeSetName, PropertyName) \ | ||
AttributeSetName->Get##PropertyName##Attribute().GetNumericValue(AttributeSetName) | ||
|
||
/** | ||
* | ||
*/ | ||
UCLASS() | ||
class FAB_API UFabAttributeSet : public UAttributeSet | ||
{ | ||
GENERATED_BODY() | ||
public: | ||
UFabAttributeSet(); | ||
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override; | ||
virtual void PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) override; | ||
virtual void PostGameplayEffectExecute(const FGameplayEffectModCallbackData& Data) override; | ||
|
||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Health, Category = "Ability | Gameplay Attribute") | ||
FGameplayAttributeData Health; | ||
ATTRIBUTE_ACCESSORS(UFabAttributeSet, Health); | ||
|
||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_MaxHealth, Category = "Ability | Gameplay Attribute") | ||
FGameplayAttributeData MaxHealth; | ||
ATTRIBUTE_ACCESSORS(UFabAttributeSet, MaxHealth); | ||
|
||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Stamina, Category = "Ability | Gameplay Attribute") | ||
FGameplayAttributeData Stamina; | ||
ATTRIBUTE_ACCESSORS(UFabAttributeSet, Stamina); | ||
|
||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_MaxStamina, Category = "Ability | Gameplay Attribute") | ||
FGameplayAttributeData MaxStamina; | ||
ATTRIBUTE_ACCESSORS(UFabAttributeSet, MaxStamina); | ||
|
||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Strength, Category = "Ability | Gameplay Attribute") | ||
FGameplayAttributeData Strength; | ||
ATTRIBUTE_ACCESSORS(UFabAttributeSet, Strength); | ||
|
||
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_MaxStrength, Category = "Ability | Gameplay Attribute") | ||
FGameplayAttributeData MaxStrength; | ||
ATTRIBUTE_ACCESSORS(UFabAttributeSet, MaxStrength); | ||
|
||
UFUNCTION() | ||
void OnRep_Health(const FGameplayAttributeData& OldHealth) const; | ||
|
||
UFUNCTION() | ||
void OnRep_MaxHealth(const FGameplayAttributeData& OldMaxHealth) const; | ||
|
||
UFUNCTION() | ||
void OnRep_Stamina(const FGameplayAttributeData& OldStamina) const; | ||
|
||
UFUNCTION() | ||
void OnRep_MaxStamina(const FGameplayAttributeData& OldMaxStamina) const; | ||
|
||
UFUNCTION() | ||
void OnRep_Strength(const FGameplayAttributeData& OldStamina) const; | ||
|
||
UFUNCTION() | ||
void OnRep_MaxStrength(const FGameplayAttributeData& OldMaxStamina) const; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.