Skip to content

Instantly share code, notes, and snippets.

@bluebright
Created February 16, 2025 07:00
Show Gist options
  • Select an option

  • Save bluebright/685320b3bbc80dd44eea0496451762a8 to your computer and use it in GitHub Desktop.

Select an option

Save bluebright/685320b3bbc80dd44eea0496451762a8 to your computer and use it in GitHub Desktop.
Spawn bp class in C++
//Header
class 당신의 클래스 이름 : public UObject
{
//여기서 원하는 BP는 "C++로 정의한 클래스"를 상속 받은 BP여야 한다.
UPROPERTY(EditAnywhere)
TSubclassOf<C++로 정의한 클래스> ActorBPClass1;
}
//Cpp
//생성자
당신의 클래스 이름::당신의 클래스 이름()
{
static ConstructorHelpers::FClassFinder<C++로 정의한 클래스> TempActorBPClass2(TEXT("레퍼런스 경로"));
if (TempActorBPClass2.Succeeded())
{
ActorBPClass1 = TempActorBPClass2.Class;
}
}
임의의 함수()
{
//임의로 만든 TempTransform는 Location, Rotation으로 대체 가능
C++로 정의한 클래스* NewActor = GetWorld()->SpawnActor<C++로 정의한 클래스>(ActorBPClass1, TempTransform)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment