0
\$\begingroup\$

What is the purpose of the Object parameter here?

UInputComponent.BindAction(..., UserClass* Object, ...)

What information should I pass here?

\$\endgroup\$
1
  • \$\begingroup\$ Usually in gamedev, if you can't imagine a use for a particular feature, then it's probably not a feature you need for the particular thing you're doing. What are you trying to accomplish with BindAction at present? Have you encountered any difficulty making that happen without using am object parameter (eg. passing null)? \$\endgroup\$
    – DMGregory
    Commented Sep 6, 2019 at 13:07

1 Answer 1

1
\$\begingroup\$

The full signature is:

template<class UserClass>
FInputActionBinding & BindAction
(
    const FName ActionName,
    const EInputEvent KeyEvent,
    UserClass * Object,
    typename FInputActionHandlerSignature::TUObjectMethodDelegate< UserClass >::FMethodPtr Func
)

This shows that UserClass is a template parameters and that TUObjectMethodDelegate uses that parameter as well. TUObjectMethodDelegatelooks to be a helper to encapsulate member functions of the template parameter type.

This means that Object is the instance object on which the passed delegate is invoked.

Which is a long winded way of saying it's unreal's typesafe alternative to a void* userData parameter commonly found in callback frameworks.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .