Is it me or FName is bugged ?

Hello i’m a newbie to Unreal Engine (in term of coding lol) I had my hand on UnrealScript in the past on Deus Ex in 1999 (haha this was so awesome !).

So i have an issue with my code in c++.

AddCharacter::AddCharacter()
{
FName(“Kitana_M0”);
SearchFName(“Kitana_M1”);
}

void SearchFName(const char* String)
{
const char* Search = String;

if(FName(Search, FNAME_Find) != NAME_None)
{
	GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Green, "Found");
}
else
{
	GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, "Name not found !");
}

}

So here the FName “Kitana_M0” is created and i’m calling my function to search for “Kitana_M1” and the FName is found (Wtf ?) i think this look for “Kitana” and skip the _M1 for some reason.

If i search for “Kitanas” then it will say it’s not found as intended, is it me that did a mistake or something else ? It seem that searching “Kitana_M1” is found cause the engine look “Kitana” only for an unknown reason.

Could someone explain how to “properly” make an “accurate” search of FName (by calling a function off course, cause i want to do it “on the fly” Thanks.

I think the main issue here is that you aren’t using the TEXT macro when creating and searching for your FName.

Try replacing


FName("Kitana_M0");
SearchFName("Kitana_M1");

with


FName(TEXT("Kitana_M0"));
SearchFName(TEXT("Kitana_M1"));