読み物
https://wvigler.hatenablog.com/entry/2021/05/10/101039
https://goolee.hatenablog.com/archive/category/GameplayAbility
https://qiita.com/koorinonaka/items/cf26af4433fda41134ac
実装時にはまった個所
Ability実行されたがGameplayEffectのコストが反映されない
CommitAbilityを呼ぶ必要がある
GameplayEffectを設定するとUEが落ちる
Abilityを実行したオブジェクトがAttributeSetを持っていない
- オブジェクト(Character,Pawnなど…
- GameplayAbilitySystem
- GameplayEffect
- ここで変化させたいパラメータ(FGameplayAttributeData)をオブジェクトが持っていないとUEが落ちる
↑のようになっていた
よく考えるとあたりまえだけど減らしたいパラメータをAbilitySystemComponentが
探すが、どこにもなくて落ちてしまっていた
FGameplayAttributeDataで設定したパラメータの同期
- UPROPERTYにReplicatedUsing = OnRep_Xxxxを追加
- OnRep_Xxxxを実装
- GAMEPLAYATTRIBUTE_REPNOTIFY(UMyAttributeSet, Xxx, ParamXxx);
- ParamXxxはOnRep_Xxxxの引数
- UMyAttributeSetにGetLifetimeReplicatedPropsをOverrride
void UMyAttributeSet::OnRep_Xxx(const FGameplayAttributeData& ParamPoint)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UMyAttributeSet, Point, ParamPoint);
}
void UMyAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME_CONDITION_NOTIFY(UMyAttributeSet, Point, COND_None, REPNOTIFY_Always);
}
Characterクラスに宣言しているAttributeSetがnullptrになってしまう
\Characterクラス名.cpp(1): error : Expected Characterクラス名.h to be first header included.
上記のような警告を解消する
Characterクラス名.hを一番初めにincludeさせるように修正
CharacterクラスのBP側でnullptrになっていたのでいろいろ調査していた
parentクラスを付け替えで一時的に元に戻ったりしていた
parentクラス付け替えはBPの設定がリセットされてしまうので本当に困っていた…
上記の解決方法ではなく実際は↓が大きな原因だった
https://qiita.com/mintiatian/items/e3236da8bb50226913f7
GPE_Initialize
Duration Policy
- Instant
- This effect applies instantly
- この効果は即座に適用されます
- CurrentValue,BaseValueが変わる
- Infinite
- This effect lasts forever
- この効果は永遠に続く
- CurrentValueが変わる
- ダメージとかに使う
- Has Duration
GameplayEffectExecutionCalculationについて
検索
GASがどこに何があるのかわからなくなったときは検索をするとどこに何が設定されているかわかる
Get Owning Actor from Actor Info 所有しているActorを取得
PlayMontageAndWait モーションの再生で使う
AbilityTask
他から参照する時
GetAbilitySystemComponent
ネットワークの設定
namespace EGameplayAbilityNetExecutionPolicy
{
/** Where does an ability execute on the network. Does a client "ask and predict", "ask and wait", "don't ask (just do it)" */
enum Type
{
// Part of this ability runs predictively on the local client if there is one
LocalPredicted UMETA(DisplayName = "Local Predicted"),
// This ability will only run on the client or server that has local control
LocalOnly UMETA(DisplayName = "Local Only"),
// This ability is initiated by the server, but will also run on the local client if one exists
ServerInitiated UMETA(DisplayName = "Server Initiated"),
// This ability will only run on the server
ServerOnly UMETA(DisplayName = "Server Only"),
};
}
Defaultで設定されているLocalPredictedは
Clientで実行
Serverでも実行
実行できたかなどはServerのものを利用する
Clientが実行した場合
Client→Server
Serverが実行した場合
Server
という流れのためServer→Clientは別の方法で実装する必要がある
↓のサイトも参考
https://x157.github.io/UE5/GameplayAbilitySystem/
Tag
それぞれのコメント。
- AbilityTags
- This ability has these tags
- このアビリティには以下のタグがあります。
- CancelAbilitiesWithTag
- Abilities with these tags are cancelled when this ability is executed
- これらのタグを持つアビリティは、このアビリティが実行されるとキャンセルされます。
- BlockAbilitiesWithTag
- Abilities with these tags are blocked while this ability is active
- このアビリティが有効な間、これらのタグを持つアビリティはブロックされる。
- ActivationOwnedTags
- Tags to apply to activating owner while this ability is active. These are replicated if ReplicateActivationOwnedTags is enabled in AbilitySystemGlobals.
- このアビリティがアクティブである間、アクティベーションを行うオーナーに適用するタグ。AbilitySystemGlobalsでReplicateActivationOwnedTagsが有効になっている場合、これらは複製される。
-
- EventActivateAbilityが呼ばれるとtrue
- EndAbilityでfalse
- ActivationRequiredTags
- This ability can only be activated if the activating actor/component has all of these tags
- この能力は、活性化するアクター/コンポーネントが以下のタグをすべて持っている場合にのみ活性化されます。
- ActivationBlockedTags
- This ability is blocked if the activating actor/component has any of these tags
- 起動するアクター/コンポーネントが以下のいずれかのタグを持っている場合、この能力はブロックされます。
- SourceRequiredTags
- This ability can only be activated if the source actor/component has all of these tags
- この能力は、ソースとなるアクター/コンポーネントが以下のタグをすべて持っている場合にのみ有効です。
- SourceBlockedTags
- This ability is blocked if the source actor/component has any of these tags
- ソースとなるアクター/コンポーネントが以下のタグのいずれかを持っている場合、この能力はブロックされます。
- TargetRequiredTags
- This ability can only be activated if the target actor/component has all of these tags
- この能力は、対象のアクター/コンポーネントが以下のタグをすべて持っている場合にのみ起動することができます。
- TargetBlockedTags
- This ability is blocked if the target actor/component has any of these tags
- 対象のアクター/コンポーネントが以下のいずれかのタグを持っている場合、この能力はブロックされます。