Why FName is not needed?

When we bind for an action like InputHandler->BindAction("Grab",IE_Pressed, this, &UGrabber::Grab), I don’t understand something.
BindAction’s signature says thats the first parameter is an FName. Instead an FName, we just passed a simple string literal. It compiles and runs well. However, if I put there FName("Grab"), it compiles too but does not work. Why?

@ben maybe?

That’s probably because you just need to give it the right value, which is an FName, namely a re-definition of the String type (as we saw in section 2 with FString etc.), and not call a funcion to return that value.
So, giving it a pointer to a char array (namely a String) equals to, or better, is effectively, giving it an FName parameter, just like it does require.

Plus doing it by calling FName would request more parameters than just the “Grab” string it appears, while returning the exact same value as directly writing “Grab” as a parameter.

Did this help @mrmudlee?

yepp

1 Like

Privacy & Terms