# Error when BindAction on UEnhancedInputComponent

**URL:** <https://forums.unrealengine.com/t/error-when-bindaction-on-uenhancedinputcomponent/533470>\
**Category:** C++\
**Tags:** Input, unreal-engine, UE5-0, question, CPP\
**Created:** [April 19, 2022, 1:15pm UTC](https://forums.unrealengine.com/t/error-when-bindaction-on-uenhancedinputcomponent/533470 "2022-04-19T13:15:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaskedFuyu](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/maskedfuyu/32/723605_2.png) [@MaskedFuyu](https://forums.unrealengine.com/u/MaskedFuyu)\
**Post date:** [April 19, 2022, 1:15pm UTC](https://forums.unrealengine.com/t/error-when-bindaction-on-uenhancedinputcomponent/533470/1 "2022-04-19T13:15:00Z")

</div>

I followed the docs trying to migrate to Enhanced Input. I ran into an error when BindAction.

This is how I call `BindAction`.

```cpp
PlayerEnhancedInputComponent->BindAction(MoveForwardAction, ETriggerEvent::Triggered, this, &APlayerCharacter::MoveForward);

```

`MoveForward` is declared like this:

```cpp
void AKusoGameCharacter::MoveForward(const FInputActionValue& Value)

```

When I compiled the code, I was given an error saying:

> Error C2664 ‘void TDelegate\<void (void),FDefaultDelegateUserPolicy\>::BindUObject\<UserClass,\>(UserClass _,void (\_\_cdecl APlayerCharacter::_ )(void))’: cannot convert argument 2 from ‘FuncType’ to ‘void (\_\_cdecl APlayerCharacter::\* )(void)’ KusoGame F:\Program Files\Epic Games\UE\_5.0\Engine\Plugins\Experimental\EnhancedInput\Source\EnhancedInput\Public\EnhancedInputComponent.h 374

It seems that it calls an overloaded version which takes the delegate without arguments. I tried create a `FEnhancedInputActionHandlerValueSignature` manually and pass it in. It still gave me same error.

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [April 19, 2022, 1:20pm UTC](https://forums.unrealengine.com/t/error-when-bindaction-on-uenhancedinputcomponent/533470/2 "2022-04-19T13:20:39Z")

</div>

Did you mark your `void MoveForward(const FInputActionValue& Value)` as `UFUNCTION()` ?  
AFAIC, input functions require it.

---

<div class="post-metadata">

**Author:** ![MaskedFuyu](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/maskedfuyu/32/723605_2.png) [@MaskedFuyu](https://forums.unrealengine.com/u/MaskedFuyu)\
**Post date:** [April 19, 2022, 1:36pm UTC](https://forums.unrealengine.com/t/error-when-bindaction-on-uenhancedinputcomponent/533470/3 "2022-04-19T13:36:13Z")

</div>

I marked, same error.

---

<div class="post-metadata">

**Author:** ![MaskedFuyu](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/maskedfuyu/32/723605_2.png) [@MaskedFuyu](https://forums.unrealengine.com/u/MaskedFuyu)\
**Post date:** [April 21, 2022, 1:39pm UTC](https://forums.unrealengine.com/t/error-when-bindaction-on-uenhancedinputcomponent/533470/4 "2022-04-21T13:39:17Z")

</div>

I tried another way to pass the handler function, it worked. But I’m still wondering why it does not compile with the raw function pointer.

Here is what I did:

```cpp
FEnhancedInputActionHandlerValueSignature::TMethodPtr<ThisClass> MethodPointer = &APlayerCharacter::MoveForward;
PlayerEnhancedInputComponent->BindAction(MoveForwardAction, ETriggerEvent::Triggered, this, MethodPointer);

```

I checked the source, found that three of the `BindAction`s are defined by a macro `DEFINE_BIND_ACTION(HANDLER_SIG)`, where `HANDLER_SIG` is one of the three kinds of delegate: `FEnhancedInputActionHandlerSignature`, `FEnhancedInputActionHandlerValueSignature`, `FEnhancedInputActionHandlerInstanceSignature`.

The generated `BindAction` will take `typename HANDLER_SIG::TMethodPtr< UserClass > Func` as the action handler.

But somehow when I pass a raw function pointer like the docs does, it calls

```auto
template< class FuncType, class UserClass, typename... VarTypes >
FEnhancedInputActionEventBinding& BindAction(const UInputAction* Action, ETriggerEvent TriggerEvent, UserClass* Object, FuncType Func, VarTypes... Vars)

```

defined on line 371 in `EnhancedInputComponent.h`

Confusing, hope someone can tell me why.

And…it seems not necessary to mark the handler function `UFUNCTION()`.
