Can't Get Enhanced Input Working in C++ "Overloaded Member Function Not Found"

I’ve spent hours now trying to get this working, I can’t see what I’m missing?

I keep getting the following error:

Severity Code Description Project File Line Suppression State Details
Error C2511 ‘void ABaseSkaterCharacter::Move(FInputActionValue &)’: overloaded member function not found in ‘ABaseSkaterCharacter’ DDCPP E:\UnrealProjects\DDCPP\Source\DDCPP\Private\Characters\BaseSkaterCharacter.cpp 28

Please can anybody help?

Header File:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "InputActionValue.h"
#include "BaseSkaterCharacter.generated.h"

class UCapsuleComponent;
class USkeletalMeshComponent;
class UInputMappingContext;
class UInputAction;

UCLASS()
class DDCPP_API ABaseSkaterCharacter : public ACharacter
{
	GENERATED_BODY()

public:

	ABaseSkaterCharacter();

	virtual void Tick(float DeltaTime) override;


	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;


protected:

	virtual void BeginPlay() override;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
	UInputMappingContext* SkateMappingContext;

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

	void Move(const FInputActionValue& Value);

};

C++ File:

// Fill out your copyright notice in the Description page of Project Settings.
#include "Characters/BaseSkaterCharacter.h"
#include "Components/InputComponent.h"
#include "EnhancedInputSubsystems.h"
#include "EnhancedInputComponent.h"



ABaseSkaterCharacter::ABaseSkaterCharacter()
{
	PrimaryActorTick.bCanEverTick = true;

}

void ABaseSkaterCharacter::BeginPlay()
{
	Super::BeginPlay();
	
	if (APlayerController* PlayerController = Cast<APlayerController>(GetController()))
	{
		if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem< UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
		{
			Subsystem->AddMappingContext(SkateMappingContext, 0);
		}
	}
}

void ABaseSkaterCharacter::Move(FInputActionValue& Value)
{
	const FVector2d MoveValue = Value.Get<FVector2d>();
	float LeanInput = MoveValue.Y;
	float SteerInput = MoveValue.X;
}


void ABaseSkaterCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}


// Input

void ABaseSkaterCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);

	// Set Up Action Bindings
	if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent))		
	{
		EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ABaseSkaterCharacter::Move);
	}

}


in .h file you’re declaring:

void Move(const FInputActionValue& Value);

but in .cpp file you’re defining:

void ABaseSkaterCharacter::Move(FInputActionValue& Value)

You forgot to add const here, it should be:

void ABaseSkaterCharacter::Move(const FInputActionValue& Value)

const makes a big difference here.

In C++ you can have two functions with same names and parameters, but if one takes const parameters and the other takes mutable (non-const) parameters, then you’re technically dealing with two different functions which is called Function Overloading. That’s why compiler is confused and says that it cannot found “overloaded member function”.

Worked like a charm, and you’ve given me some extra reading material as well which is much appreciated.

Thanks so much for your help!

1 Like