Hello all.
I want to create an Actor in C++, and this Actor is defined with Blueprint.
So, I tried this code below.
UClass* Class = NULL;
UObject* uobj = StaticLoadObject(UBlueprint::StaticClass(), NULL,TEXT("Blueprint'/Game/Project/Blueprints/TestCharacter.TestCharacter'"));
if (uobj != NULL) {
UBlueprint* blueprint = Cast(uobj);
Class = blueprint->GeneratedClass;
}
FTransform SpawnTransform;
FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = CollisionHandlingOverride;
AActor* act = GetWorld()->SpawnActor(Class, &SpawnTransform, SpawnParameters);
It works fine when I run this in the UE4Editor.
But in a packaged game, StaticLoadObject() returns NULL.
In addition, I could create this Actor from Blueprint-to-C++ function like this in the same packaged game.
So, I think ‘TestCharacter Actor’ is cooked and included in a game package.
AActor* AMyTest::SpawnActor(UClass* Class, FTransform SpawnTransform, ESpawnActorCollisionHandlingMethod CollisionHandlingOverride)
I’m using UE 4.10.1, and packaged for Windows 64bit.
Could you give me some advices?
Thanks in advance.