1 创建Actor/AuraEffectActor类,删掉Tick函数
2 在AuraEffectActor.h中
创建TObject<USphereComponent> Sphere;
重写virtual void OnOverlap(UPrimitiveCompinent* Overlap...);
重写virtual void EndOverlap(UPrimitiveCompinent* Overlap...);
TObject<UStaticMeshComponent> Mesh
3 在AuraEffectActor.cpp中
给上面的初始化:
构造中:
PrimaryActorTick.bCanEverTick = false;
Sphere = CreateDefaultSubobject<USphereComponent>("Sphere");
Mesh= CreateDefaultSubobject<UStaticMeshComponent>("Mesh");
SetRootComponent(Mesh);
Sphere ->SetupAttachment(GetRootComponent());
BeginPlay()
{
Sphere->OnComponentBeginOverlap.AddDynamic(this,&AAuraEffectActor::OnOverlap);
Sphere->OnComponentEndOverlap.AddDynamic(this,&AAuraEffectActor::EndOverlap);
}
OnOverlap()
{
if(IAbilitySystemInterface* ASCInterface = Cast<IAbilitySystemInterface>(OtherActor))
{
//TODO: Change this to apply a Gameplay Effect. FOr now using const_cast as a back!
cosnt UAuraAttributeSet* AuraAttributeSet = ASCInterface->GetAbilitySystemComponent()->GetAttributeSet(UAuraAttributeSet::StaticClass());
UAuraAttributeSet* MutableAuraAttributeSet = const_cast<UAuraAttributeSet*>(AuraAttributeSet);
MutableAuraAttributeSet ->SetHealth(AuraAttributeSet->GetHealth() + 25.f);
Destory();
}
}
4 在内容浏览器中创建Actor文件夹、BP_HealthPotion
在蓝图中,添加相应的静态网格体
浙公网安备 33010602011771号