I got this working, but I’m not really sure WHY it’s working… I set up my C++ Character and used the following to set up the UInputComponent:
BaseCharacter.h
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
BaseCharacter.cpp
void ABaseCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
// Set up "movement" bindings.
PlayerInputComponent->BindAxis("MoveForward", this, &ABaseCharacter::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &ABaseCharacter::MoveRight);
// Set up "look" bindings
PlayerInputComponent->BindAxis("Turn", this, &ABaseCharacter::AddControllerYawInput);
PlayerInputComponent->BindAxis("LookUp", this, &ABaseCharacter::AddControllerPitchInput);
}
Then I wanted to create a subclass of BaseCharacter:
SubCharacter.h
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
SubCharacter.cpp
void AJumperCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
// New action bindings go here
}
The difference is in the BaseCharacter.h the parameters include “**class **UInputComponent” whereas the SubCharacter.h only needs “UInputComponent”. Could someone please explain what’s going on there? I’m glad it works, but it’d be good to know why.
Cheers