이것저것

[UE4] BoxComponent Overlap C++ 사용 본문

[언리얼] Unreal Engine 4/기록해두자..

[UE4] BoxComponent Overlap C++ 사용

Patch_JA 2019. 8. 13. 11:42
728x90

C++에서 BoxComponent나 CapsuleComponent같은 콜리전 충돌여부 함수

// Header
    
UFUNCTION()
  	void OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

 

// CPP

ClassName::ClassName()
{
	m_pBoxComponent->OnComponentBeginOverlap.AddDynamic(this, &ClassName::OnOverlapBegin);
}

void ClassName::OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	if (OtherActor && (OtherActor != this) && OtherComp) 
	{
		// ... 태그를 활용해서 구분해도 됨.
	}
}

그밖에 End도 존재

 

기본적인 Event 관련해서는https://api.unrealengine.com/KOR/Engine/Blueprints/UserGuide/Events/index.html#eventactorbeginoverlap

Comments