[UE5] AttachToComponent

ChangJin·2024년 1월 2일
0

Unreal Engine5

목록 보기
24/102
post-thumbnail

공식 문서를 참고해보면...

https://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/GameFramework/AActor/AttachToComponent/

해당 액터에 제공된 컴포넌트의 RootComponent를 노출시킬 수 있습니다.


  • 다음처럼 Cast로 해당 UPrimitiveComponent를 가지고 있는지 판단한 후에 SetSimulatePhysics로 해당 물리판정을 비활성화하고 AttachToComponent로 RootComponent를 노출시킬 수 있습니다.

	AActor* actor = GetAcceptableActor();
	if(actor != nullptr)
	{
		UPrimitiveComponent* Component = Cast<UPrimitiveComponent>(actor->GetRootComponent());
		if (Component != nullptr)
		{
			Component->SetSimulatePhysics(false);
		}
		actor->AttachToComponent(this, FAttachmentTransformRules::KeepWorldTransform);
		Mover->SetShouldMove(true);
	}
	else
	{
		Mover->SetShouldMove(false);
	}
profile
Unreal Engine 클라이언트 개발자

0개의 댓글