Download

Trouble With BindAxis

Hello everyone!

I am new to Unreal 4 and UE in general, I mostly did my previous programming work in C# and in Unity more specifically but I decided to switch, and unfortunately this engine is frustrating me.
I am not much of a C++ programmer but I know the core concepts and as a tutorial for myself i decided to create my own FPS character, the problem arises in the BindAxis function. Everything is set up exactly like in the tutorials
and in the basic FPS character, yet I get an error specifically on the “->” part of the calling

void AMyCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
check(InputComponent)
Super::InputComponent->BindAxis(“MoveForward”, this, &AMyCharacter::MoveForward);

}

This is the intellisense error: 4 IntelliSense: no instance of overloaded function “UInputComponent::BindAxis” matches the argument list
argument types are: (const char [12], AMyCharacter , void (AMyCharacter::)())
object type is: UInputComponent c:\Users\dando_000\Desktop\Work\Project\Learning\MyProject2\Source\MyProject2\MyCharacter.cpp 33 23 MyProject2

These are the compiler’s errors:

1.Error 1 error C2664: ‘FInputAxisBinding &UInputComponent::BindAxis(const FName)’ : cannot convert argument 3 from ‘void (__cdecl AMyCharacter::* )(void)’ to ‘void (__cdecl AMyCharacter::* )(float)’ C:\Users\dando_000\Desktop\Work\Project\Learning\MyProject2\Source\MyProject2\MyCharacter.cpp 33 1 MyProject2

2.Error 2 error : Failed to produce item: C:\Users\dando_000\Desktop\Work\Project\Learning\MyProject2\Binaries\Win64\UE4Editor-MyProject2.pdb C:\Users\dando_000\Desktop\Work\Project\Learning\MyProject2\Intermediate\ProjectFiles\ERROR MyProject2

3.Error 3 error MSB3073: The command ““C:\Program Files\Epic Games\4.7\Engine\Build\BatchFiles\Build.bat” MyProject2Editor Win64 Development “C:\Users\dando_000\Desktop\Work\Project\Learning\MyProject2\MyProject2.uproject” -rocket” exited with code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets 38 5 MyProject2

Hi Dazzor, the AMyCharacter::MoveForward method needs to take a float argument.

Two things:

Your SetupInputComponent should only need the class designator in your .h file.

Your MoveForward function should have this signature: void AMyCharacter::MoveForward(float Value)

1 Like

Could you tell me please why can’t I use let’s say a “const float& Value” instead of a “float Value” even if I don’t want to change Value