Variable loses value after ToText

Not sure i understand this one. I’ve seen a few other similar posts but no answer seems to work for me.

any ideas why my variable has a value but after ToText is called the value is lost?

Are you sure? Breakpoints cut the execution before the node they are on is executed.

Can you “Step Over” and see if the value is filled?

Can you also show the watched variables in the “Blueprint Debugger” tab as (for me) the bubbles are hard to track.

I suspect that the “ToText (string)” node does not return a proper value from the screenshot but I’ll have to try it.

Well. I’m getting “Variable not in scope” error on the image and totext part.

Oh how silly of me. I was deleting the object while this was all happening… That’s why half way through it loses reference. MAtttt Daemmonnnn

I was deleting the object:

void AInteractiveActor::PickUp_Implementation(AActor* item)
{
	if (item->GetClass()->ImplementsInterface(UInteractiveItem::StaticClass()))
	{
		IInteractiveItem* interactiveItem = Cast<IInteractiveItem>(item);
		if (AInventoryItem* inventoryItem = Cast<AInventoryItem>(interactiveItem))
		{
			APlayerPawnController* playerPawnController = Cast<APlayerPawnController>(GetWorld()->GetFirstPlayerController());
			playerPawnController->PlayerPawn->Inventory->InventoryItems.Add(Cast<AInventoryItem>(inventoryItem));
			//item->Destroy();
			playerPawnController->HideActionsMenu();
			playerPawnController->ShowInventory(inventoryItem);
		}
	}
}

so half way through the blueprint running, the ref was removed. Clever me :slight_smile: