Created
February 16, 2025 07:00
-
-
Save bluebright/685320b3bbc80dd44eea0496451762a8 to your computer and use it in GitHub Desktop.
Spawn bp class in C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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