Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. /** This is inside the HandleUpdate method */
  2. [...]
  3.         int faceTo=0;
  4. [...]
  5.         /** Bopper controls */
  6.         if(input->GetKeyDown(KEY_W))
  7.         {
  8.             moveDir += Vector3::FORWARD;
  9.             faceTo+=0;
  10.         }
  11.         if(input->GetKeyDown(KEY_A))
  12.         {
  13.             moveDir += Vector3::LEFT;
  14.             faceTo+=270;
  15.         }
  16.         if(input->GetKeyDown(KEY_S))
  17.         {
  18.             moveDir += Vector3::BACK;
  19.             faceTo+=180;
  20.         }
  21.         if(input->GetKeyDown(KEY_D))
  22.         {
  23.             moveDir += Vector3::RIGHT;
  24.             faceTo+=90;
  25.         }
  26. [...]
  27.         // character rotates to face the direction of player input
  28.         if(faceTo > 180) // duct tape for 315° rotations
  29.             faceTo+=360;
  30.         if(moveDir.x_ != 0 && moveDir.z_ != 0) // duct tape for in-between rotations
  31.             faceTo/=2;
  32.  
  33.         if(moveDir.x_ != 0 || moveDir.z_ != 0)
  34.         {
  35.             Quaternion faceThis=Quaternion(0,faceTo,0);
  36.             chara_->SetWorldRotation(cameraNode_->GetWorldRotation() * faceThis);
  37.             if(moveDir.x_ != 0 && moveDir.z_ < 0) // duct tape for 135° and 225° rotations
  38.                 chara_->Yaw(180);
  39.         }
  40. [...]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement