example:
UPROPERTY(BlueprintReadOnly,EditAnywhere,Category = "Attributes")
TSubclassOf<UGameplayEffect> DefaultPrimaryAttributes;
void InitializePrimaryAttributes()const;

void AAuraCharacterBase::InitializePrimaryAttributes() const
{
check(IsValid(GetAbilitySystemComponent()));
check(DefaultPrimaryAttributes);
const FGameplayEffectContextHandle ContextHandle = GetAbilitySystemComponent()->MakeEffectContext();
const FGameplayEffectSpecHandle SpecHandle = GetAbilitySystemComponent()->MakeOutgoingSpec(DefaultPrimaryAttributes,1.f,ContextHandle);
GetAbilitySystemComponent()->ApplyGameplayEffectSpecToTarget(*SpecHandle.Data.Get(),GetAbilitySystemComponent());
}
posted on 2025-08-27 15:24  偷懒的阿贤  阅读(7)  评论(0)    收藏  举报