GAS_Aura-Constructing the ASC and AS

1 在AuraCharacterBase.h中

protected:

TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent;

TObjectPtr<UAttributeSet> AttributeSet;

2 在AuraEnemy.cpp中

构造中

{

  AbilitySystemComponent = CreateDefaultSubobject<UAbilitySystemComponent>("AbilitySystemComponent");

  AbilitySystemComponent->SetIsReplicated(true);

 

  AttributeSet = CreateDefaultSubobject<AuraAttributeSet>("AttributeSet");

}

3 在AuraPlayerState.h中

protected:

TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent;

TObjectPtr<UAttributeSet> AttributeSet;

4 在AuraPlayerState.cpp中

构造函数

{

AbilitySystemComponent = CreateDefaultSubobject<UAbilitySystemComponent>("AbilitySystemComponent");

  AbilitySystemComponent->SetIsReplicated(true);

 

  AttributeSet = CreateDefaultSubobject<AuraAttributeSet>("AttributeSet");

}

 

5 在AuraCharacterBase.h中

AuraCharacterBase类的继承增加public IAbilitySystemInterface

重写GetAbilitySystemComponent() const;

UAttributeSet* GetAttributeSet() const {return AttributeSet;}

 

6 在AuraPlayerState.h中

AuraPlayerState类的继承增加public IAbilitySystemInterface

重写GetAbilitySystemComponent() const;

UAttributeSet* GetAttributeSet() const {return AttributeSet;}

posted @ 2025-08-12 19:22  蜡笔小新紫南  阅读(5)  评论(0)    收藏  举报