Async Loading SoftObjectPtr to Primary Data Asset

I’m trying to load in a data asset softobjectptr asynchronously when I interact with a computer terminal actor. I found this tutorial on how to load it in the way I was expecting but it seems to failing at the last stage with the resultant pointer to the presumably loaded content being invalid.

bool ATerminalBase::AttemptInteraction_Implementation(UInteractComponent* Interactor)
{
	// Get the Asset Manager from anywhere
	if (UAssetManager* Manager = UAssetManager::GetIfValid())
	{
		UMiniGameDebugFunctionLibrary::DebugLogWithObject(this, "Initial Manager Is Valid");
		
		FPrimaryAssetId GameId = TerminalMiniGame_DataAsset->GetPrimaryAssetId();

		UMiniGameDebugFunctionLibrary::DebugLogWithObject(this, "Primary ID: " +GameId.ToString());
		// Optional "bundles" like "UI"
		TArray<FName> Bundles;
		
		// Delegate with parameters we need once the asset had been loaded
		FStreamableDelegate Delegate = FStreamableDelegate::CreateUObject(this,&ATerminalBase::OnDataLoaded, GameId);
    
		UMiniGameDebugFunctionLibrary::DebugLogWithObject(this, "Loading Data");
		// The actual async load request
		Manager->LoadPrimaryAsset(GameId, Bundles, Delegate);
	}
	
	return Super::AttemptInteraction_Implementation(Interactor);
}

void ATerminalBase::OnDataLoaded(FPrimaryAssetId LoadedId)
{
	UMiniGameDebugFunctionLibrary::DebugLogWithObject(this, "Game Data Has Loaded");
	UAssetManager* Manager = UAssetManager::GetIfValid();
	if (Manager)
	{
		UMiniGameDebugFunctionLibrary::DebugLogWithObject(this, "Asset Manager is Valid");
		UTerminalMiniGame_PDA* TerminalData= Cast<UTerminalMiniGame_PDA>(Manager->GetPrimaryAssetObject(LoadedId));

		if (TerminalData)
		{
			UMiniGameDebugFunctionLibrary::DebugLogWithObject(this, "Game Data Is Valid");
		}
	}
}

Here is the output log, with the object name removed for the sake of readability:

LogBlueprint: Warning: Initial Manager Is Valid
LogBlueprint: Warning: Primary ID: TerminalMiniGame_PDA:TerminalTest_DA
LogBlueprint: Warning: Loading Data
LogAssetManager: Warning: Invalid Primary Asset Id TerminalMiniGame_PDA:TerminalTest_DA: ChangeBundleStateForPrimaryAssets failed to find NameData
LogBlueprint: Warning: Interactable Received Attempt to Interact
LogBlueprint: Warning: Game Data Has Loaded
LogBlueprint: Warning: Asset Manager is Valid

That warning about the Invalid Primary Asset Id is probably what is causing the error. But I am overriding it in the parent class of the data asset and am definitely including it in the asset manager portion of the project settings:

image

FPrimaryAssetId UTerminalMiniGame_PDA::GetPrimaryAssetId() const
{
	return FPrimaryAssetId("TerminalMiniGame_PDA", GetFName());
}

If anyone could point out where I am going wrong as I am truly out of ideas for what could be causing this, I would be very grateful :slight_smile:

Hey , can you tell more about the code because its not fully clear like how you are using TerminalMiniGame_DataAsset and one more thing before using Interactor just add a IsValid check that if you are passing the correct pointer or not. And for reference I have done this async loading from the following tutorial so you can also check it once and it is good How To Create An Asynchronous Loading System In UE5 (Overview) #UE5 #C++ #IndieDev - YouTube