GAS GameplayEffect
This article contains 267 words.
GAS GameplayEffect
初始化
我们在
AuraCharacter里初始化了角色信息, InitAbilityActorInfo里有个 InitializeDefaultAttributes()操作,这个操作在 AuraCharacterBase里定义,具体代码为: 1
2
3
4
5
6
7// 这个函数是对角色设置了
Primary、Secondary、Vital 属性的默认值
void AAuraCharacterBase::InitializeDefaultAttributes() const
{
ApplyEffectToSelf(DefaultPrimaryAttributes, 1.f);
ApplyEffectToSelf(DefaultSecondaryAttributes, 1.f);
ApplyEffectToSelf(DefaultVitalAttributes, 1.f);
}敌人属性初始化在
AuraEnemy里的 InitAbilityActorInfo,同样是调用父类的InitializeDefaultAttributes(),具体代码为:1
2
3
4
5
6
7void AAuraEnemy::InitAbilityActorInfo()
{
AbilitySystemComponent->InitAbilityActorInfo(this, this);
Cast<UAuraAbilitySystemComponent>(AbilitySystemComponent)->AbilityActorInfoSet();
InitializeDefaultAttributes();
}然后我们就在继承自
AuraEnemy的蓝图里配置要初始化的属性值,这时候,继承自这个蓝图的敌人就会有这些默认属性值了。
我们这个例子是生成火球,所以我们再去火球的蓝图里配置GE。
在GA 蓝图里生成火球后,我们就能在火球重叠时触发对应的效果了。 AuraProjectile里 OnSphereOverlap函数里有个对 OtherActor的
ApplyGameplayEffectSpecToSelf函数,这个函数就是应用 GE 的函数。然后生成的 AuraprojectileSpell的里面我们有配置 DamageEffectSpecHandle,GE属性又在 AuraAttributeSet里触发 PostGameplayEffectExecute。