Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var lastWorldOrientation = getHMDOrientation();//This method returns world space orientation
- var displayedOrientation = lastWorldOrientation;
- void Update() {
- var nowWorldOrientation = getHMDOrientation();
- var delta;
- if (lockedYaw) { //null if not locked, else float with value yaw locked to
- var tempLast = lastWorldOrientation;
- var tempNow = nowWorldOrientation;
- tempLast.eulerAngles.y = lockedYaw;
- tempNow.eulerAngles.y = lockedYaw;
- delta = tempLast:toObjectSpace(tempNow);
- } else {
- delta = lastWorldOrientation:toObjectSpace(nowWorldOrientation);
- }
- lastWorldOrientation = nowWorldOrientation;
- displayedOrientation = displayedOrientation * delta;
- camera.rotation = displayedOrientation;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement