Skip to main content
Up and Coming
June 10, 2015

Unity 5.1 FPS Controller Question

I have the new VR Supported Mode working now and removed all OVR Prefabs in place of Unity FPS controller, but one strange thing I just noticed.

The OVR FPS controller would use your head forward facing position when you walk or "Sprint" forward so you were moving towards where you were looking. Felt great and correct,

The standard unity FPS controller walks or Sprints but doesn't seem to update to your forward looking position as well, the result is looking forward but moving sideways a lot of the time.

It took me a while to figure out why I was all of a sudden getting major motion sickness feelings on my scenes that felt fine before.

Is there a checkbox somewhere I could use to correct this or am I missing something somewhere?. Thanks

I can provide links to two scenes, one built in 5.0.2 and one in 5.1 if that is helpful.
    This topic has been closed for replies.

    19 replies

    Up and Coming
    June 15, 2015
    Excellent, thank you so much cybereality, I will try that out.
    j.j. morris - tekrok - https://share.oculus.com/app/tekrok
    Up and Coming
    June 17, 2015
    After some more experimenting I found there is what seems to be a bug with 5.1 in regards to spawning anything at the head position / rotation. I can repro this 100% and its a weird one, took a long time to find.

    Unless there are 2 x FPS character controller prefabs in the scene objects spawned won't use the correct head position.

    With just one it's all broken, but add a second one and it's all fine except now framerate is suffering.

    I imagine people know about this and it might be fixed in the next version, just mentioning it in case anyone has the same issues.
    j.j. morris - tekrok - https://share.oculus.com/app/tekrok
    Up and Coming
    June 19, 2015
    The solution above doesn't work for me because I have an avatar body attached to my FirstPersonController. So even though the character is moving in the direction of where the player is looking, the character itself remains pointing in the original direction.

    What I did was integrate in the HmdRotatesY feature from OVRPlayerController.

    Make the following changes to FirstPersonController.cs

    1. Insert this public attribute to control the feature:

    			public bool HmdRotatesY = true;


    2. Insert this code at the bottom of Start():

    			// HmdRotatesY parent object
    GameObject cameraParent = new GameObject("Camera Parent");
    cameraParent.transform.SetParent(m_Camera.transform.parent, false);
    m_Camera.transform.SetParent(cameraParent.transform, false);



    3. Insert this code into the start of RotateView():

    			if (HmdRotatesY)
    {
    Transform root = m_Camera.transform.parent;
    Transform centerEye = m_Camera.transform;

    Vector3 prevPos = root.position;
    Quaternion prevRot = root.rotation;

    transform.rotation = Quaternion.Euler(0.0f, centerEye.rotation.eulerAngles.y, 0.0f);

    root.position = prevPos;
    root.rotation = prevRot;

    // Reset the mouse look to our new orientation
    m_MouseLook.Init(transform, m_Camera.transform);
    }

    That's it. Now as with OVR SDK you can turn on/off the HmdRotatesY as needed. And your avatar models will rotate correctly.

    Hope that helps!

    Peter
    Check out my Unity VR development blog: http://talesfromtherift.com @peterept
    Inspiring
    June 19, 2015
    Thanks for sharing. Very helpful.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    June 22, 2015
    I am still experiencing the 0.6.0 problem in Unity 5.1 where the HMD doesn't move the the camera and doesn't goto direct to rift in play mode. So I went back to 5.0.3.

    But I was worried about this, thanks for the code and the API reference. Seems way more straight forward than the old OVR API -- nothing personal Oculus devs, built in integration is just more simple 99% of the time ;)

    Glad to know I can get "swivel-chair mode" working this easy.

    Any word on an ETA on a fix or 0.6.1 update, cybereality? :)
    Inspiring
    June 22, 2015
    @HappySlice: If head-tracking is not working at all, and doesn't go into direct to rift mode, then that sounds like a bug and a totally separate issue from this topic. Please create a new thread with more details (logs, etc. viewtopic.php?f=34&t=23521 ) and I can look into it further.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    August 17, 2015
    thanks for the head forward tip!
    "Vector3 desiredMove = m_Camera.transform.forward * m_Input.y + m_Camera.transform.right * m_Input.x;"

    should be a buildin option :-)
    Participant
    August 23, 2015
    Thanks for your tips.

    Vector3 desiredMove = m_Camera.transform.forward * m_Input.y + m_Camera.transform.right * m_Input.x;
    DK2 Ordered: 3rd August 2014
    New Participant
    January 6, 2018
    Thanks for this guys, for those who want the same thing, this lil tweak works like a charm after nights of experiments and trying to figure out! :) Thank you.
    Vector3 desiredMove = m_Camera.transform.forward * m_Input.y + m_Camera.transform.right * m_Input.x;