void AARCharacter::MoveForward(float Value) { if ((Controller != NULL) && (Value != 0.0f)) { //if (Value < 0) //{ // float orignal = CharacterMovement->MaxWalkSpeed; // CharacterMovement->MaxWalkSpeed = CharacterMovement->MaxWalkSpeed / 2; // FRotator Rotation = GetBaseAimRotation(); // FVector Location; //not used, just need for below. // //Controller->GetPlayerViewPoint(Location, Rotation); // Rotation.Normalize(); // FRotator YawRotation(0, Rotation.Yaw, 0); // //const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis( EAxis::X ); // const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X); // AddMovementInput(Direction, Value); // CharacterMovement->MaxWalkSpeed = orignal; // return; //} FRotator Rotation = GetBaseAimRotation(); FVector Location; //not used, just need for below. //Controller->GetPlayerViewPoint(Location, Rotation); Rotation.Normalize(); FRotator YawRotation(0, Rotation.Yaw, 0); //const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis( EAxis::X ); const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X); AddMovementInput(Direction, Value); } }
void AARCharacter::MoveRight(float Value) { if ( (Controller != NULL) && (Value != 0.0f) ) { FRotator Rotation; FVector Location; //not used, just need for below. Controller->GetPlayerViewPoint(Location, Rotation); Rotation.Normalize(); FRotator YawRotation(0, Rotation.Yaw, 0); const FVector Direction = FRotationMatrix(YawRotation).GetScaledAxis(EAxis::Y); // add movement in that direction AddMovementInput(Direction, Value); } }
void AARCharacter::MoveForward(float Value) { if ((Controller != NULL) && (Value != 0.0f)) { // find out which way is forward FRotator Rotation = GetBaseAimRotation(); FVector Location; //not used, just need for below. //Controller->GetPlayerViewPoint(Location, Rotation); Rotation.Normalize(); FRotator YawRotation(0, Rotation.Yaw, 0); const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X); AddMovementInput(Direction, Value); } }