Advertisement
Guest User

Untitled

a guest
May 9th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1.  
  2. void ABDPlayerController::MoveForward(float Value)
  3. {
  4.     if (Value != 0.0f)
  5.     {
  6.         // find out which way is forward
  7.         const FRotator Rotation = GetControlRotation();
  8.         const FRotator YawRotation(0, Rotation.Yaw, 0);
  9.  
  10.         // get forward vector
  11.         const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
  12.         GetPawn()->AddMovementInput(Direction, Value);
  13.     }
  14. }
  15.  
  16. void ABDPlayerController::MoveRight(float Value)
  17. {
  18.     if (Value != 0.0f)
  19.     {
  20.         // find out which way is right
  21.         const FRotator Rotation = GetControlRotation();
  22.         const FRotator YawRotation(0, Rotation.Yaw, 0);
  23.  
  24.         // get right vector
  25.         const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
  26.         // add movement in that direction
  27.         GetPawn()->AddMovementInput(Direction, Value);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement