Hello.
FActorSpawnParameters SpawnParams;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
AMyFurnitureActor* myFurniture = GWorld->GetWorld()->SpawnActor<AMyFurnitureActor>(MyItemBlueprint, location, rotation, SpawnParams);
Yeah, it's spawned... But not in game - only in UE Editor window: Initial level:
![some](https://camo.githubusercontent.com/3fcc3f896cb5acc658e68702bc5bd1f4deae5c1ce1c399f41c9cd983acbb4f95/68747470733a2f2f616e73776572732e756e7265616c656e67696e652e636f6d2f73746f726167652f74656d702f39313233332d73637265656e73686f745f3234322e706e67)
After code execution there are no furniture actor in game:
![some](https://camo.githubusercontent.com/395e076c6fcc3014fb23a9e4624d80b81fb124ccdd34b8a32f33325236c83c5d/68747470733a2f2f616e73776572732e756e7265616c656e67696e652e636f6d2f73746f726167652f74656d702f39313233342d73637265656e73686f745f3234332e706e67)
it present in UE Editor:
![some](https://camo.githubusercontent.com/8d45d0a1f36749b58cde05692de32daeeb31c33a2c435a07df72e98871140a69/68747470733a2f2f616e73776572732e756e7265616c656e67696e652e636f6d2f73746f726167652f74656d702f39313233352d73637265656e73686f745f3234342e706e67)
Why this code spawning actors in UE Editor, but not in game?
I have some level with GameMode override BaseLevelGameMode BP.
In the BaseLevelGameMode Player Controller is MainPlayerController.
AMyFurnitureActor* ULoadFunctions::MyLoadFurnitureObjectByName(const FString FurnitureName, FVector location, FRotator rotation, UWorld* World)
{
UObjectLibrary * lib = UObjectLibrary::CreateLibrary(AMyFurnitureActor::StaticClass(), true, true);
FString name = "";
if (FurnitureName.EndsWith(TEXT("_C"))) {
name = FurnitureName.Left(FurnitureName.Len() - 2);
}
lib->AddToRoot();
int32 loaded = lib->LoadBlueprintAssetDataFromPath("/Game/");
TArray<FAssetData> Assets;
lib->GetAssetDataList(Assets);
for (int32 i = 0; i < Assets.Num(); ++i) {
FAssetData& assetData = Assets[i];
FString assetDataObjectPath = assetData.ObjectPath.ToString();
if (assetDataObjectPath.EndsWith(name)) {
auto cls = StaticLoadObject(UObject::StaticClass(), nullptr, *assetDataObjectPath);
UBlueprint * bp = Cast<UBlueprint>(cls);
TSubclassOf<class UObject> MyItemBlueprint;
MyItemBlueprint = (UClass*)bp->GeneratedClass;
World = GWorld->GetWorld();
if (World) {
FActorSpawnParameters SpawnParams;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
AMyFurnitureActor* myFurniture = World->SpawnActor<AMyFurnitureActor>(MyItemBlueprint, location, rotation, SpawnParams);
return myFurniture;
}
else {
return nullptr;
}
}
}
return nullptr;
}
If game started in Standalone game mode, furniture spawned in game, not in UE Editor...
Why Event, that Binded to OnRequestComplete received UE Editor as World, but not my games world? IE, why it's spawned not in game, but in UE Editor?
And how to fix that?