Why FName is not needed?

urc_s03_introducing_input_binding

#1

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?


#2

@ben maybe?


#3

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.


#4

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.


#5

Did this help @mrmudlee?


#6

yepp