오버랩(Overlap)은 두 액터(Actor)가 서로의 충돌 범위(콜리전 영역) 안에 들어올 때 발생하는 이벤트입니다. 이 이벤트는 충돌 처리(Collision Handling)와는 다르게 물리적 충돌 없이도 실행되며, 게임 내 다양한 상호작용을 구현하는 데 사용됩니다.
OverlapAllDynamic).Mesh: Static Mesh 컴포넌트.Sphere: 충돌 감지 범위를 정의하는 구(Sphere).Mesh = CreateDefaultSubobject<UStaticMeshComponent>("Mesh");
SetRootComponent(Mesh);
Sphere = CreateDefaultSubobject<USphereComponent>("Sphere");
Sphere->SetupAttachment(GetRootComponent());
OverlappedComponent: 충돌을 감지한 컴포넌트.OtherActor: 충돌한 다른 액터.OtherComp: 충돌한 액터의 컴포넌트.OtherBodyIndex: 충돌한 바디의 인덱스.bFromSweep: 스윕 충돌 여부.SweepResult: 충돌에 대한 추가 정보.void AAuraEffectActor::OnOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if (IAbilitySystemInterface* ASCInterface = Cast<IAbilitySystemInterface>(OtherActor))
{
const UAuraAttributeSet* AuraAttributeSet = Cast<UAuraAttributeSet>(
ASCInterface->GetAbilitySystemComponent()->GetAttributeSet(UAuraAttributeSet::StaticClass()));
UAuraAttributeSet* MutableAuraAttributeSet = const_cast<UAuraAttributeSet*>(AuraAttributeSet);
MutableAuraAttributeSet->SetHealth(AuraAttributeSet->GetHealth() + 25.f);
Destroy(); // 포션 삭제
}
}
Sphere->OnComponentBeginOverlap.AddDynamic(this, &AAuraEffectActor::OnOverlap);
Sphere->OnComponentEndOverlap.AddDynamic(this, &AAuraEffectActor::EndOverlap);
Delegate와 Callback 바인딩:
Ability System Interface 활용:
속성 관리 및 변경: