BindAction fourth argument

I have a problem with BindAction. It wont accept a function with an argument in it.

ShooterCharacter.h

private:
	
	void LookUp(float AxisValue);
	void MoveForward(float AxisValue);
	void Move();

ShooterCharacter.cpp

void AShooterCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);

	PlayerInputComponent->BindAxis(TEXT("LookUp"), this, &AShooterCharacter::LookUp);
	PlayerInputComponent->BindAction(TEXT("Jump"), EInputEvent::IE_Pressed, this, &AShooterCharacter::Jump);
	PlayerInputComponent->BindAction(TEXT("MoveForward"), EInputEvent::IE_Pressed, this, &AShooterCharacter::MoveForward);
	PlayerInputComponent->BindAction(TEXT("MoveForward"), EInputEvent::IE_Pressed, this, &AShooterCharacter::Move);

}

void AShooterCharacter::MoveForward(float AxisValue) 
{
	AddMovementInput(GetActorForwardVector() * AxisValue);
}
void AShooterCharacter::Move() 
{

}

For the BindAction with Move or Jump, I dont have any problems. But with MoveForward which take a float parameter, it fails :

No viable function. Argument types: const wchar_t[12], EInputEvent, AShooterCharacter*, void(AShooterCharacter::)(float). Candidates considered: FInputActionBinding& BindAction(const FName ActionName, const EInputEvent KeyEvent, UserClass Object, FInputActionHandlerSignature::TMethodPtr Func) (in class UInputComponent) conversion of 4th argument &AShooterCharacter::MoveForward is ill-formed: cannot convert void(AShooterCharacter::)(float) to parameter type FInputActionHandlerSignature::TMethodPtr, because source function has 1 parameter, but target function doesn’t have parameters FInputActionBinding& BindAction(const FName ActionName, const EInputEvent KeyEvent, UserClass Object, FInputActionHandlerWithKeySignature::TMethodPtr Func) (in class UInputComponent) conversion of 4th argument &AShooterCharacter::MoveForward is ill-formed: cannot convert void(AShooterCharacter::)(float) to parameter type FInputActionHandlerWithKeySignature::TMethodPtr, because source function and target function have different 1st parameter types: float and FKey FInputActionBinding& BindAction<DelegateType, UserClass, VarTypes…>(const FName ActionName, const EInputEvent KeyEvent, UserClass Object, DelegateType::TMethodPtr Func, VarTypes… Vars) (in class UInputComponent) cannot infer substitution for DelegateType

EDIT :
Dumb me stopped the video and tried to solve the problem like a dumbass, instead a playing it full, to see Sam correct it with BindAxis two minutes later…

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms