Pass a value through bindaction?

Hi! Is it possible to have a function with arguments with bindaction?

I would like to trigger the same function with press and release of the same button but with a bool as true or false.

Or do I have to duplicate each function for each input?

Thanks!

1 Like

You cannot pass dynamic arguments, but you can pass constants. You can use template functions if you like, but I prefer this method. You can do all of this in the CPP which means no extra function declarations.



DECLARE_DELEGATE_OneParam(FCustomInputDelegate, const bool);
InputComponent->BindAction<FCustomInputDelegate>("OnSomeInput", IE_Pressed, this, &AMyActor::OnInput, true);

DECLARE_DELEGATE_TwoParams(FAnotherCustomInputDelegate, const bool, const float);
InputComponent->BindAction<FAnotherCustomInputDelegate>("OnSomeOtherInput", IE_Pressed, this, &AMyActor::OnOtherInput, true, 10.f);


You can pass as many params as you like, you just need to declare a different delegate type.

6 Likes

Beautiful! That’s exactly what I was looking for, thanks!