Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. var lastWorldOrientation = getHMDOrientation();//This method returns world space orientation
  2. var displayedOrientation = lastWorldOrientation;
  3. void Update() {
  4. var nowWorldOrientation = getHMDOrientation();
  5. var delta;
  6.  
  7. if (lockedYaw) { //null if not locked, else float with value yaw locked to
  8. var tempLast = lastWorldOrientation;
  9. var tempNow = nowWorldOrientation;
  10. tempLast.eulerAngles.y = lockedYaw;
  11. tempNow.eulerAngles.y = lockedYaw;
  12.  
  13. delta = tempLast:toObjectSpace(tempNow);
  14. } else {
  15. delta = lastWorldOrientation:toObjectSpace(nowWorldOrientation);
  16. }
  17.  
  18. lastWorldOrientation = nowWorldOrientation;
  19. displayedOrientation = displayedOrientation * delta;
  20. camera.rotation = displayedOrientation;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement