Greetings,
I’m trying to create a similar movement to this: Moving Out Gameplay on Youtube.
So far, I was able to set the movement to four directions. The code is this:
// Called to bind functionality to input
void ACharacterActor::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
// Set up "movement" bindings.
PlayerInputComponent->BindAxis("MoveForward", this, &ACharacterActor::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &ACharacterActor::MoveRight);
// Set up "action" bindings.
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacterActor::StartJump);
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacterActor::StopJump);
}
void ACharacterActor::MoveForward(float Value)
{
// Find out which way is "forward" and record that the player wants to move that way.
FVector Direction = FRotationMatrix(Controller->GetControlRotation()).GetScaledAxis(EAxis::X);
Direction.Normalize();
AddMovementInput(Direction, Value);
}
void ACharacterActor::MoveRight(float Value)
{
// Find out which way is "right" and record that the player wants to move that way.
FVector Direction = FRotationMatrix(Controller->GetControlRotation()).GetScaledAxis(EAxis::Y);
Direction.Normalize();
AddMovementInput(Direction, Value);
}
void ACharacterActor::StartJump()
{
bPressedJump = true;
}
void ACharacterActor::StopJump()
{
bPressedJump = false;
}
I want to rotate the player towards movement.
Any help will be appreciated.