Get Display Name returning null

Hey, I’m using the blueprint node “Get Display Name” linked off the "Hit Actor’ return value from a “Get Hit Result Under Cursor by Channel” node. This works as expected until I package my game in to a standalone at which point it only seems to work on one particular actor in the scene.

Okay so I have figured out what is actually happening now. “Get Display Name” returns the actor name that you would find in the content browser when running the game in the editor, but when run as a standalone it returns the actor name thats found in the scene outliner. I’m not sure why it does this, and I can’t seem to find a C++ function either to return the original actor/asset name. Some help would be much appreciated

For me it is returning the name of the scene element. If i have multiple copies of my BP in it, it will print the Name it has in the scene outliner. This could match the name of the original BP but most of the time it has a unique number behind.

So i don’t think you get the name of the actor that it has in the contentbrowser at all.

You could get the class instead. Like “MyBlueprint_C”. Just use “GetClass” and print the DisplayName of the returning class.

Excuse the delay, had essays to write and such. For anyone that comes by this post looking for an answer feel free to use this code segment that I came up with (Thanks to enlight on IRC for suggesting to use the ParseIntoArray function).

I wouldn’t recommend using this on any strings of sizable length, it is in no way efficient at all. It also won’t work if your naming conventions for actors use numbers in them at all.

FString AProject::GetDisplayName(AActor* a_actor)
{	
	FString name = a_actor->GetName();

	// Pass the string in to an array of strings, delimetered by(and consequently removing): "_"
	// I didn't see the need to iterate from the back as the names are short, this will remove ALL numbers
	TArray<FString> nameArray;
	name.ParseIntoArray(&nameArray, TEXT("_"), true);
	for ( int32 i = 0; i < nameArray.Num(); ++i )
	{
		if ( nameArray[i].IsNumeric() )
		{
			nameArray[i] = "";
		}
	}

	// Remove any empty strings, e.g; the numbers we set to ""
	// Done this way to avoid resizing the array within the for loop
	FString::CullArray(&nameArray);

	// Rebuild the string, appending "_" where appropriate.
	FString output;
	for (int32 i = 0; i < nameArray.Num(); ++i)
	{
		output.Append(nameArray[i]);

		if ( i == nameArray.Num() - 1 )
			break;

		output.Append(TEXT("_"));
	}

	return output;
}