Download

Level Streaming C++ Error

I am trying to save the current levels that are loaded to an Array to save in a file save system so when the player loads the game back up i can fully recycle and stream in the current levels streamed in. This is the error im receiving.

2>D:\Users\dark5\Documents\Unreal Projects\darkstorm\Source\darkstorm\darkstormCharacter.cpp(379): error C2664: ‘int32 TArray<ULevel,FDefaultAllocator>::AddUnique(const ULevel &)’: cannot convert argument 1 from ‘ULevel *’ to ‘ULevel &&’
2> D:\Users\dark5\Documents\Unreal Projects\darkstorm\Source\darkstorm\darkstormCharacter.cpp(379): note: Reason: cannot convert from ‘ULevel *’ to ‘ULevel’
2> D:\Users\dark5\Documents\Unreal Projects\darkstorm\Source\darkstorm\darkstormCharacter.cpp(379): note: No constructor could take the source type, or constructor overload resolution was ambiguous

TArray &lt;ULevel&gt;* SaveLevelsActive;

Defined in my Save File ^



const TArray<ULevelStreaming*>& StreamedLevels = GetWorld()->StreamingLevels;

	for (const ULevelStreaming* EachLevelStreaming : StreamedLevels)
	{
		if (!EachLevelStreaming)
		{
			continue;
		}

		ULevel* EachLevel = EachLevelStreaming->GetLoadedLevel();


	


		//Is This Level Valid and Visible?
		if (!EachLevel || !EachLevel->bIsVisible)
		{
			continue;
		}

		//Print Name of current Level Streaming to know which level the unit is in!
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, EachLevelStreaming->GetWorldAssetPackageName());
		SaveGameInstance->SaveLevelsActive->AddUnique(EachLevel);

	}



The issue is that u try to store a pointer to a non-pointer

Change


TArray <ULevel>* SaveLevelsActive;

to


TArray <ULevel*>* SaveLevelsActive;

wow i feel stupid now >.<. Your a life safer i didn’t know i had to do that…