Hi,
I’m trying to move a pawn using the WASD keys. I am using the following code:
RDDPStrategyPawn.h
UFUNCTION()
void MoveUp(float Val);
UFUNCTION()
void MoveRight(float Val);
RDDPStrategyPawn.ccp
void ARDDPStrategyPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
Super::SetupPlayerInputComponent(InputComponent);
InputComponent->BindAxis("MoveUp", this, &ARDDPStrategyPawn::MoveUp);
InputComponent->BindAxis("MoveRight", this, &ARDDPStrategyPawn::MoveRight);
}
void ARDDPStrategyPawn::MoveUp(float Value)
{
if ((Controller != NULL) && (Value != 0.0f))
{
FRotator Rotation = Controller->GetControlRotation();
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
}
void ARDDPStrategyPawn::MoveRight(float Value)
{
if ((Controller != NULL) && (Value != 0.0f))
{
const FRotator Rotation = Controller->GetControlRotation();
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
AddMovementInput(Direction, Value);
}
}
It compiles and runs just fine, and works perfectly on a Character-type pawn. However, movement controls do not work when applied to a blank pawn. Am I missing something obvious?
Regards, Rob