Download

Can't setup Input Component in Player Controller

Trying to do the simple thing of Setting up an InputComponent in a Controller to get inputs instead in the Character Class. It makes sense to have the player input handled and cleaned up while its still in the controller. seemed easy enough. I’ve seen other people use the exact same code in tutorials, but with this im getting no instance of “UInputComponent::BindAxis” matches the argument list.

Spent the day Banging my head against the wall. I feel like a toad. months of learning and tutorials and I cant implement the very first part of the code of a game.

CharacterPlayerController.h :


#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "CharacterPlayerController.generated.h"

/**
*
*/
UCLASS()
class ROADOFPUNCHING_API ACharacterPlayerController : public APlayerController
{
GENERATED_BODY()

public:
virtual void SetupInputComponent() override;

void Right();
void Left();
};

CharacterPlayerController.cpp:




#include "CharacterPlayerController.h"
#include "Components/InputComponent.h"



void ACharacterPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();


InputComponent->BindAxis(TEXT("Right"), this, &ACharacterPlayerController::Right);
InputComponent->BindAxis("Left", this, &ACharacterPlayerController::Left);
}

void ACharacterPlayerController::Right()
{
UE_LOG(LogTemp, Warning, TEXT("Right."));
}

void ACharacterPlayerController::Left()
{
UE_LOG(LogTemp, Warning, TEXT("Left."));
}

E:\Unreal Engine\Unreal Projects\RoadOfPunching\Source\RoadOfPunching\CharacterPlayerController.cpp(14) : error C2664: ‘FInputAxisBinding &UInputComponent::BindAxis<ACharacterPlayerController>(const FName,UserClass ,void (__cdecl ACharacterPlayerController:: )(float))’: cannot convert argument 3 from ‘void (__cdecl ACharacterPlayerController::* )(void)’ to ‘void (__cdecl ACharacterPlayerController::* )(float)’

Save me.

If I’m not mistaken, binding axis functions has to have a float param, that’s what they expect.



void Right(float AxisValue);
void Left(float AxisValue);


Thank you you are a saint. I have been lifted from the depths of confusion, onto a slightly higher platform of humility.

Bind Action and Bind Axis behave very differently, should have checked that sooner.