I’m trying to add a new control axis to handle vertical movement while floating in zero gravity. Pressing “R” should make the player go upwards, and pressing “F” should make the player go downwards. I’m pretty sure I’ve done everything right, but the new buttons aren’t doing anything in the test game.
My .h file has this:
/** Handle directional thrust */
void MoveForward(float Val);
void MoveRight(float Val);
void MoveUp(float Val);
My .cpp file has this:
void ATestProjectCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
check(InputComponent);
InputComponent->BindAxis("MoveForward", this, &ATestProjectCharacter::MoveForward);
InputComponent->BindAxis("MoveRight", this, &ATestProjectCharacter::MoveRight);
InputComponent->BindAxis("MoveUp", this, &ATestProjectCharacter::MoveUp);
InputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
InputComponent->BindAxis("TurnRate", this, &ATestProjectCharacter::TurnAtRate);
InputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
InputComponent->BindAxis("LookUpRate", this, &ATestProjectCharacter::LookUpAtRate);
}
void ATestProjectCharacter::MoveForward(float Value)
{
if (Value != 0.0f)
{
AddMovementInput(GetActorForwardVector(), Value);
}
}
void ATestProjectCharacter::MoveRight(float Value)
{
if (Value != 0.0f)
{
AddMovementInput(GetActorRightVector(), Value);
}
}
void ATestProjectCharacter::MoveUp(float Value)
{
if (Value != 0.0f)
{
AddMovementInput(GetActorUpVector(), Value);
}
}
And my project settings has this:
(Don’t worry I’m not trying to use a controller)
So… obviously I’m missing something here, but I can’t think of what.