Hi So my problem is that I can’t seem to move my Pawn from my PlayerController, I am very new to ue4 and have been looking for more information but can’t seem to solve my problem.
I have the pawn and the player controller class assigned in the game mode class (It is also set as the main game mode in the settings):
PlayerControllerClass = ADefaultPlayerController::StaticClass();
DefaultPawnClass = ATSSPawn::StaticClass();
Now for my “Move Forward” Method which is bound to the axis, I have tried a couple of solutions and only 1 of them works and I am not sure if this is the right way to do it.
void ADefaultPlayerController::MoveForward(float Value)
{
APawn* const MyPawn = GetPawn();
if (MyPawn && Value != 0.0f) {
//Doesn't work
FRotator Rotation = GetControlRotation();
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
MyPawn->AddMovementInput(Direction, Value);
//Doesn't work
MyPawn->AddMovementInput(MyPawn->GetActorUpVector(), Value);
//Works
FVector NewLocation = MyPawn->GetTargetLocation();
NewLocation.X += Value;
MyPawn->SetActorLocation(NewLocation);
}
}
I would like to know why does the AddMovementInput function doesn’t work in this case? What did I miss or what do I don’t understand?