I’m trying to append the data table of a struct, I don’t know how… want to achieve the same as you can see in this blueprint graph.
It is a simple FString::Append. So, similar code to that blueprint would be:
FString Str = HoldWeapon;
Str.Append("_");
Str.Append(Posture);
Str.Append("_");
Str.Append(MoveState);
Thank You very much, You just solved the problem… I was trying to implement it using UKismet Library.
and the return value need to be converted to type Name
and set to Data Table Row input
You can use UKismetStringLibrary::Conv_StringToName to convert FStringTo FName. Don’t forget to include Kismet/KismetStringLibrary.h.
FString Str = "smth";
FName Name = UKismetStringLibrary::Conv_StringToName(Str);
So it is not possible to convert not using UKismet Library?
I think yes, it’s possible. Try to pass to FName constructor FString value (I don’t remember which is correct: FName(Str) or FName(*Str)).
FString value(FName(*Str));
this works , so its mean now I have the return of the append is Str
and I can set it to the (get data table by row) as connected in the bp graph ?
Well… I didn’t mean like this, just FName(*Str)
, but yes, append, cast to FName and there is a ready parameter for GetDataTableRow.
The full code example (you can write it in a different ways):
FString Str = HoldWeapon;
Str.Append("_");
Str.Append(Posture);
Str.Append("_");
Str.Append(MoveState);
FYourDataTableStructType* Data = YourDataTable->FindRow<FYourDataTableStructType>(FName(*Str), "");
(FindRow is a C++ version of blueprint GetDataTableRow)
Thank You very very much for helping, still a little confusion, How to get the outerr row
in which I have Forward
and Other
to set the walk speed
.
if (const UDataTable* DT_WalkSpeed{ LoadObject<UDataTable>(GetWorld(), TEXT("/Game/my data table")) })
{
if (const FST_WalkSpeed* Row { DT_WalkSpeed->FindRow<FST_WalkSpeed>(FName(*Str), "") })
{
if (MoveForwardAxis > 0.0f)
{
WalkSpeed = Forward;
}
else
{
WalkSpeed = Other;
}
}
}
Function FindRow in sucsess return a pointer to structure. All you need to save this pointer (it’s
const FST_WalkSpeed* Row { DT_WalkSpeed->FindRow<FST_WalkSpeed>(FName(*Str), "") }
in your code) and access the member of structure by operator ->
(it’s because you have only pointer, not struct itself). So, try this:
if (const UDataTable* DT_WalkSpeed{ LoadObject<UDataTable>(GetWorld(), TEXT("/Game/my data table")) })
{
if (const FST_WalkSpeed* Row { DT_WalkSpeed->FindRow<FST_WalkSpeed>(FName(*Str), "") })
{
if (MoveForwardAxis > 0.0f)
{
WalkSpeed = Row->Forward;
}
else
{
WalkSpeed = Row->Other;
}
}
}
Thank You Sir very very much , You just solved my Problem and I really appreciate the time You have spent on this Issue to solve.
Really this is a big achievement , Thank You very much