Search Unity

GearVR Oculus viewer with cockpit

Discussion in 'AR/VR (XR) Discussion' started by 714714, Sep 23, 2016.

  1. 714714

    714714

    Joined:
    Sep 23, 2016
    Posts:
    5
    Trying to develop a GearVR game that has a cockpit. Problem is am having is integrating the first person with the cockpit. I made a cockpit and tried making the oculus viewer a child of it but it does not stay with the cockpit.

    Tried making the cockpit a child of the viewer. It does stick with that but the cockpit moves with where you look. Not sure what I am missing. If someone can point me to a tutorial I would be very grateful.

    Thanks
     
  2. hassank

    hassank

    Joined:
    Nov 18, 2015
    Posts:
    48
    I do not know of a tutorial but would be happy to try and help if you provide more info. What do you mean "the cockpit moves with where you look"? Also are you using the OVR plugins or the standard camera with "Virtual Reality Supported"?
     
  3. 714714

    714714

    Joined:
    Sep 23, 2016
    Posts:
    5
    Thanks for the help. I am using the ovr plug in. When you make the cockpit a child of the viewer it moves like a gun would in a first person shooter. I look to the left and the cockpit moves to the left, I look right and the whole cockpit moves to the right. Instead of me looking out the right side of the cockpit I am looking to the right but through the front window.

    Maybe I should start over by saying... how would you setup a cockpit so that you move with it using the ovr plug in. As though you are a pilot.
     
  4. 714714

    714714

    Joined:
    Sep 23, 2016
    Posts:
    5
    Don't be shy... I read pm's also. Please help.
     
  5. 714714

    714714

    Joined:
    Sep 23, 2016
    Posts:
    5
  6. hassank

    hassank

    Joined:
    Nov 18, 2015
    Posts:
    48
    Yo - somehow I missed your alerts when I checked in over the weekend but happy to help! By default, a child transform follows the behavior of a parent transform. For example, if the parent moves or rotates, the child moves or rotates by the same amount. The inverse is not true: a parent transform does not follow the transform of the child. Those are the root causes of your issues.

    It's hard to give an exact solution since I do not know the full details of your project, but I can give you a start on a quick solution. You can lock the rotation of the cockpit to the initial rotation. Make your cockpit a child of your OVRPlayerController and attach the following:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class LockRotation : MonoBehaviour {
    5.     Quaternion initialRotation;
    6.  
    7.     // Use this for initialization
    8.     void Start () {
    9.         initialRotation = transform.rotation;
    10.     }
    11.  
    12.     // LateUpdate runs after all Update functions have been called
    13.     void LateUpdate () {
    14.         transform.rotation = initialRotation;
    15.     }
    16. }
    17.  
    The code stores the initial rotation of the object and resets the rotation after all Update functions are called. In your case, the OVRPlayerController rotates the Cockpit, but the script later resets the Cockpit's rotation. The drawback is you would need to build on the solution to be able to rotate the Cockpit. For example, if the player can use a gamepad to rotate the cockpit, you'll need to apply rotations to initialRotation so that the Cockpit is reset to the correct position. In that case, it might be easier to use the OVRCameraRig instead of the OVRPlayerController and create a controller of your own.
     
  7. Kylan

    Kylan

    Joined:
    Jan 30, 2012
    Posts:
    7
    Hi 714714. Did you manage to adapt that to GearVR?
     
  8. jpthedp

    jpthedp

    Joined:
    Sep 28, 2016
    Posts:
    1
    Sorry to but in here, but I tried creating a new thread and apparently it was too spammy...

    It seems like folks in this thread might be able to help out. I need someone who can develop an app to play video tours on Samsung Gear VR. Relatively basic functionality I guess, we would have to collaborate on the design aesthetically.

    If you have any leads that would be greatly appreciated.
     
  9. hassank

    hassank

    Joined:
    Nov 18, 2015
    Posts:
    48
  10. 714714

    714714

    Joined:
    Sep 23, 2016
    Posts:
    5
    HassanK

    I finally got a chance to try this out... Using the Camera Rig looks like the solution. The Player Controller has some weird stuff tied to it when it comes to rigid body and if you tie it to something the gravity gets wonky.

    I say it looks like the solution because I am having lunch and the only USB cable that will allow my phone to be recognized by my laptop is at home... But I tied the Camera rig to the cockpit and it looks like it is attached... I tested with the gearvr look script that mostly everyone uses and I think it is going to work just fine. I don't think I have anything planned for this evening so I will test with it a bit later and let you know...


    THANK YOU! THANK YOU! THANK YOU!