-4

I am trying to use enhanced input components in Unreal 5.1 but I get this error:

CryptRaiderCharacter.cpp(91): [C2665] ‘UEnhancedInputComponent::BindAction’: none of the 4 overloads could convert all the argument types

The line of the error:

void ACryptRaiderCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
  ...
  if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent))
    {
        EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ACryptRaiderCharacter::Move);   // error here   
    }

}


void ACryptRaiderCharacter::Move(FInputActionValue& Value)
{
    const float DirectionValue = Value.Get<float>();
    if (Controller && DirectionValue != 0.f)
    {
        FVector Forward = GetActorForwardVector();
        AddMovementInput(Forward, DirectionValue);      
    }
}

Declarations

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input)
UInputAction* MoveAction;

void Move(FInputActionValue& Value);

What is the problem ?

zac
  • 4,495
  • 15
  • 62
  • 127
  • Hard to say given the information given (plus my lack of knowledge of this API) but the declaration of `ACryptRaiderCharacter::Move` seems highly relevant. Please include that in your question. – john Apr 08 '23 at 14:24
  • Also I don't know if it makes any difference in this case, but you should specify which version of unreal engine you are using, and remove the tag for the other version. – john Apr 08 '23 at 14:26

1 Answers1

1

Found solution Move function need to be like this:

void ACryptRaiderCharacter::Move(const FInputActionValue &Value)

zac
  • 4,495
  • 15
  • 62
  • 127
  • This was exactly what was wrong with mine. I forgot my const on both my header and my imp. – alm2022 Aug 26 '23 at 15:00
  • Yes I found this solution hardly from Unreal platform I dont know why when I ask Unreal questions here they just downvote it !!! – zac Aug 27 '23 at 16:05