FName LEV_Mode = "_PLAY_";
int32 LEV_Current = 10;
FName LevelJump = "LEV_" + LEV_Current; // OK
FName LevelJump = "LEV" + LEV_Mode + LEV_Current // ERROR!
UGameplayStatics::OpenLevel(GetWorld(), LevelJump);
How to join 2 FNames without converting it all into strings?
Natalo77
(Natalo77)
January 13, 2022, 9:48am
2
I know what each type does in principle, however, the variables tutorial skips any explanation of Name and Text variables in context of each. I have seen this but it is isn’t that contextual. Is there some general rule-of-thumb that can be applied...
Reading time: 2 mins đź•‘
Likes: 10 ❤
This post should help you
The only workaround for joining FNames was to convert to a FString, do my concatenations, then convert back again.
Dumb. Me or FName?
eblade
(eblade)
January 14, 2022, 6:38pm
4
In general, FNames are usually something you aren’t stringing together dynamically. What a re you using this dynamically built FName for?
just to get names dynamically of level to load
LEV_001, LEV_002, LEV_003 …
The built in UE static uses an FName for the level reference…so I built my concatenate function using FNames…well bad idea!
1 Like
Natalo77
(Natalo77)
January 17, 2022, 8:14am
6
I don’t think you want to be using or operating on FNames until you absolutely need them.
Reahreic
(Reahreic)
September 8, 2025, 3:25pm
7
Here’s another example of needing to concatenate two FNames.
void UMyWidget::PostEditChangeProperty(FPropertyChangedEvent& e) {
if (e.GetMemberPropertyName() + e.GetPropertyName() == GET_MEMBER_NAME_CHECKED(UMyWidget, configStruct.state)) {
StateChanged_Event(configStruct.state);
}
}
That said, AFAIK the following is all you can do.
FName memberName = e.GetMemberPropertyName();
FName propertyName = e.GetPropertyName();
FName combined = FName(memberName.ToString() + "." + propertyName.ToString());
IrSoil
(IrSoil)
September 8, 2025, 9:22pm
8
I’d like to note that both of those options are NOT ok:
FName LevelJump = "LEV_" + LEV_Current;
FName LevelJump = "LEV" + LEV_Mode + LEV_Current;
In first case you doing char* + int
which doesn’t have sence in given context.
In second case - you can’t concat FName with int directly and have to convert this int to string type first. Hence, something along the lines should work:
FName LevelJump = FName(”LEV_” + LEV_Mode.ToString() + FString::FromInt(LEV_Current));
Iirc FName
s are supposed to be static, so you have to make your math on regular strings first.