Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** This is inside the HandleUpdate method */
- [...]
- int faceTo=0;
- [...]
- /** Bopper controls */
- if(input->GetKeyDown(KEY_W))
- {
- moveDir += Vector3::FORWARD;
- faceTo+=0;
- }
- if(input->GetKeyDown(KEY_A))
- {
- moveDir += Vector3::LEFT;
- faceTo+=270;
- }
- if(input->GetKeyDown(KEY_S))
- {
- moveDir += Vector3::BACK;
- faceTo+=180;
- }
- if(input->GetKeyDown(KEY_D))
- {
- moveDir += Vector3::RIGHT;
- faceTo+=90;
- }
- [...]
- // character rotates to face the direction of player input
- if(faceTo > 180) // duct tape for 315° rotations
- faceTo+=360;
- if(moveDir.x_ != 0 && moveDir.z_ != 0) // duct tape for in-between rotations
- faceTo/=2;
- if(moveDir.x_ != 0 || moveDir.z_ != 0)
- {
- Quaternion faceThis=Quaternion(0,faceTo,0);
- chara_->SetWorldRotation(cameraNode_->GetWorldRotation() * faceThis);
- if(moveDir.x_ != 0 && moveDir.z_ < 0) // duct tape for 135° and 225° rotations
- chara_->Yaw(180);
- }
- [...]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement