Graylord
(Graylord)
April 14, 2020, 7:12am
1
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
Jambax
(Jambax)
April 14, 2020, 8:04am
2
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
Graylord
(Graylord)
April 14, 2020, 12:49pm
3
Beautiful! That’s exactly what I was looking for, thanks!