Linker errors when using UStreamingLevelKismet::LoadLevelInstance

Hi,

LoadLevelInstance declaration is missing ENGINE_API. To make it work you will need to add it in LevelStreaming.h.
Like this

ENGINE_API static ULevelStreamingKismet* LoadLevelInstance(

We will add this change in next engine release version (4.18). Or you can use this function from blueprints, this way you will not need to change engine files.

Edit, it should be

static ENGINE_API ULevelStreamingKismet* LoadLevelInstance(

Hey everyone,

I’m trying to implement some basic procedural dungeon generation. I have created a couple of rooms for the dungeon and saved them as UMaps. I want to load instances of these levels into a persistent dungeon level. I am trying to use UStreamingLevelKismet::LoadLevelInstance to load in these levels but I keep getting linker errors when trying to do this in c++.

void ADungeonGenerator::PlaceRoom()
{
	// Determine room size

	int RoomIndex = FMath::RandRange(0, FilteredRooms.Num() - 1);

	FRoomTypeStruct RoomTypeToPlace = FilteredRooms[RoomIndex];

	int RoomNumberToPlace = FMath::RandRange(0, RoomTypeToPlace.NumberOfRooms - 1);

	FString Tileset;
	if (CurrentTileset.GetValue() == ETileset::EDefault)
	{
		Tileset = "Default/";
	}
	FString MapPath;
	FString LevelName = MapsDirectoryRoot + Tileset + "Rooms/" + FString::FromInt(RoomTypeToPlace.TilesX) + "x" + FString::FromInt(RoomTypeToPlace.TilesY) + "/Room" + FString::FromInt(RoomNumberToPlace);
	
	UE_LOG(LogTemp, Log, TEXT("Loading %s"), *LevelName);

	bool IsRoomLoaded;

	ULevelStreamingKismet* StreamedRoom = ULevelStreamingKismet::LoadLevelInstance(this, LevelName, FVector(0, 0, 0), FRotator(0, 0, 0), IsRoomLoaded);
}

I have the header file included at the top

#include "Runtime/Engine/Classes/Engine/LevelStreamingKismet.h"

Yet I keep getting this error when trying to compile:

error LNK2019: unresolved external symbol “public: static class ULevelStreamingKismet * __cdecl ULevelStreamingKismet::LoadLevelInstance(class UObject *,class FString const &,struct FVector const &,struct FRotator const &,bool &)” (?LoadLevelInstance@ULevelStreamingKismet@@SAPEAV1@PEAVUObject@@AEBVFString@@AEBUFVector@@AEBUFRotator@@AEA_N@Z) referenced in function “protected: void __cdecl ADungeonGenerator::PlaceRoom(void)” (?PlaceRoom@ADungeonGenerator@@IEAAXXZ)

Does anyone have any idea what I am doing wrong here? I haven’t been able to find many detailed examples online of doing this in c++ so any help would be appreciated. Thank you!

Got it, I’ll just call the blueprint function for now, thanks for the quick reply!