Hey! I’ve a very simple question I think, and I’d appreciate any help!
Basiclly, my player is moving faster when it moves in diagonal, I’ve readen in other posts that normalize is what I need. But I don’t know how to modify my code to do it…
Thank you so much! This is the code:
void AMyCharacter::MoveForward(float axisValue)
{
const FVector direction = GetActorForwardVector();
AddMovementInput(direction, playerSpeed*axisValue);
}
void AMyCharacter::MoveRight(float axisValue)
{
const FVector direction = GetActorRightVector();
AddMovementInput(direction, playerSpeed*axisValue);
}
// Called every frame
void AMyCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis("MoveForward", this, &AMyCharacter::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &AMyCharacter::MoveRight);
}