Unreal C++ Overlap

주찬환·2024년 12월 22일

Unreal

목록 보기
8/12
post-thumbnail

Overlap

오브젝트간에 충돌체가 겹쳤을때 충돌판정을 내고 충돌시 이벤트를 작업하는 기능이다.

ActorOverlap

액터 간의 충돌 판정을 관리 할때 사용한다.

//OnActorBeginOverlap
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams( FActorBeginOverlapSignature, AActor, OnActorBeginOverlap, AActor*, OverlappedActor, AActor*, OtherActor );

//OnActorEndOverlap
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams( FActorEndOverlapSignature, AActor, OnActorEndOverlap, AActor*, OverlappedActor, AActor*, OtherActor );

UnrealEngine에서 위와 같은 Delegate로 정의 되어 있다.
매개 변수에서 (자료형, 변수 타입, 이름)순으로 정의되어 있으며, 이 Delegate에 묶일 함수는 반드시 앞의 3개의 매개변수를 제외한 (AActor* OverlappedActor, AActor* OtherActor )의 형식으로 가져야 한다.

//예시
UFUNCTION()
void 함수명 (AActor* OverlappedActor, AActor* OtherActor );

Delegate를 사용하기 위해선 반드시 직렬화 되어야 함으로 UFUNCTION()키워드를 통해서 직렬화 해주고 Delegate와 같은 형식의 매개변수를 가져야한다.

ComponentOverlap

컴포넌트 간의 충돌판정을 위해 사용하며 같은 액터내에서도 특정 컴포넌트에만 반응하기 때문에 조금더 정밀한 사용이 가능하다.

//OnComponentBeginOverlap
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SixParams( FComponentBeginOverlapSignature, UPrimitiveComponent, OnComponentBeginOverlap, UPrimitiveComponent*, OverlappedComponent, AActor*, OtherActor, UPrimitiveComponent*, OtherComp, int32, OtherBodyIndex, bool, bFromSweep, const FHitResult &, SweepResult);

//OnComponentEndOverlap
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams( FComponentEndOverlapSignature, UPrimitiveComponent, OnComponentEndOverlap, UPrimitiveComponent*, OverlappedComponent, AActor*, OtherActor, UPrimitiveComponent*, OtherComp, int32, OtherBodyIndex);

앞에서 기술했듯이 앞의 3개의 매개 변수를 제외한 매개변수의 홀수는 타입, 짝수는 변수명의 형식으로 함수를 정의해야한다.

//예시
FUNCTION()
	void 함수명(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
profile
게임 개발자가 되고 싶습니다! #Unreal #C++

0개의 댓글