Search Unity

UFPS OVR Camera Rig

Discussion in 'AR/VR (XR) Discussion' started by yoolee, Mar 3, 2016.

  1. yoolee

    yoolee

    Joined:
    Mar 3, 2016
    Posts:
    14
    Hello All

    I purchased UFPS and I'm having nothing but trouble getting the OVR camera rig attached to the Hero.

    I searched through the forum and UFPS forum and read that there is a way to do it but you have to figure it out until the update 1.7 .

    I tried dropping it into the main Hero folder and the weapon camera folder but i cant get it to work correctly in the DK2.

    I'm lost is there any tutorial or anyone that has made it happen that can help ?

    Thanks for any help
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Do you absolutely need to use the OVR camera rig? Unity 5 has built-in VR support.Just tick "Virtual Reality Supported" in your player settings.

    For UFPS, I use a script like this to make the UFPS character face the direction the player's headset is looking:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. /// <summary>
    5. /// If using a VR device, when the player moves, this component rotates the player in
    6. /// the direction that the camera is looking. Also sets forward rendering in VR mode
    7. /// if specified to prevent some image effect issues with deferred rendering.
    8. /// </summary>
    9. public class VRMoveInHeadsetDirection : MonoBehaviour
    10. {
    11.  
    12.     public bool useForwardRenderingInVR = true;
    13.  
    14.     private vp_FPCamera m_fpCamera;
    15.     private vp_FPPlayerEventHandler m_fpPlayer;
    16.  
    17.     private IEnumerator Start()
    18.     {
    19.         yield return null; // Wait 1 frame to let UFPS start up first.
    20.         m_fpPlayer = FindObjectOfType<vp_FPPlayerEventHandler>();
    21.         m_fpCamera = (m_fpPlayer != null) ? m_fpPlayer.GetComponentInChildren<vp_FPCamera>() : null;
    22.         if (Debug.isDebugBuild) Debug.Log("VR Device: " + UnityEngine.VR.VRSettings.loadedDevice + " (enabled=" + UnityEngine.VR.VRSettings.enabled + ")");
    23.         var isVREnabled = UnityEngine.VR.VRSettings.enabled && (UnityEngine.VR.VRSettings.loadedDevice != UnityEngine.VR.VRDeviceType.None);
    24.         enabled = isVREnabled && (m_fpPlayer != null) && (m_fpCamera != null);
    25.         if (enabled && useForwardRenderingInVR)
    26.         {
    27.             m_fpCamera.GetComponent<Camera>().renderingPath = RenderingPath.Forward;
    28.             m_fpCamera.enabled = false; // Refresh the camera settings in forward mode.
    29.             yield return null;
    30.             m_fpCamera.enabled = true;
    31.         }
    32.     }
    33.  
    34.     private void Update()
    35.     {
    36.         if ((m_fpPlayer != null) && (m_fpPlayer.Velocity.Get().magnitude > 0.1f))
    37.         {
    38.             m_fpPlayer.Rotation.Set(new Vector2(m_fpPlayer.transform.rotation.eulerAngles.x, m_fpCamera.transform.rotation.eulerAngles.y));
    39.             UnityEngine.VR.InputTracking.Recenter();
    40.         }
    41.     }
    42. }
     
  3. yoolee

    yoolee

    Joined:
    Mar 3, 2016
    Posts:
    14
    Hello TonyLi

    Thanks for the response I will try it when I get home .

    The only reason why I thought I needed the OVR Camera rig was because the dk2 does not turn on in unity when I press play if I dont have the OVR rig in the scene .

    Should it be turning on with just the Check in the settings ?

    Thanks
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Yes. I recommend creating a new Unity 5.3+ project and importing Unity's VR Samples. This is a good way to start experimenting with Oculus in Unity. Don't import it into your UFPS project. VR Samples is a complete project asset; it would overwrite your UFPS complete project settings.
     
  5. yoolee

    yoolee

    Joined:
    Mar 3, 2016
    Posts:
    14
    Hello

    I have had a chance to play with the VR samples they are great.

    So I found out why the dk2 was not turning on when I pressed play without the ovr cam rig in the scene. My settings were on dx9 instead of dx11 .

    I updated that and now the dk2 turns on when I press play with no ovr cam rig . But now i can actually see my body instead of being connected to it in the head position . Will the script above fix that ? I have already created it but Im not sure where to put it .

    Thanks
     
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Try this script. I just tested it with the Hero prefab, and it works fine.

    Code (csharp):
    1. using UnityEngine;
    2.  
    3. public class VRMoveInHeadsetDirection : MonoBehaviour
    4. {
    5.  
    6.     private vp_FPCamera m_fpCamera;
    7.     private vp_FPPlayerEventHandler m_fpPlayer;
    8.  
    9.     void Start()
    10.     {
    11.         m_fpCamera = FindObjectOfType<vp_FPCamera>();
    12.         m_fpPlayer = FindObjectOfType<vp_FPPlayerEventHandler>();
    13.         enabled = UnityEngine.VR.VRSettings.enabled && (m_fpCamera != null) && (m_fpPlayer != null);
    14.     }
    15.  
    16.     void Update()
    17.     {
    18.         if (m_fpPlayer.Velocity.Get().magnitude > 0.1f)
    19.         {
    20.             m_fpPlayer.Rotation.Set(new Vector2(m_fpPlayer.transform.rotation.eulerAngles.x, m_fpCamera.transform.rotation.eulerAngles.y));
    21.             UnityEngine.VR.InputTracking.Recenter();
    22.         }
    23.     }
    24. }
     
  7. yoolee

    yoolee

    Joined:
    Mar 3, 2016
    Posts:
    14
    Hello TonyLi

    I tried the script above and it seems to be putting the camera in the correct place. The problem I'm noticing is I am getting a fish eye view effect in the dk2.

    Example: when I walk up to a wall and look up instead of getting the feel of height from the wall it bring the top of the wall right in front of me as if I'm standing in front of the top of the wall .

    When I use the OVR camera rig it gives size and scale to everything in the scene correctly . Is there a way to take the fish eye effect off the hero or apply the OVR camera rig to the hero ?

    Thanks
     
  8. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    It's probably best to bring this to the UFPS forum to get advice from UFPS experts. I don't think it would be easy to apply the OVR camera rig to the UFPS hero. Check the settings on the OVR camera against the settings on Hero/FPSCamera. Maybe the FOV (field of view) is different, or maybe FPSCamera has some extra post-processing effects.
     
  9. yoolee

    yoolee

    Joined:
    Mar 3, 2016
    Posts:
    14
    Hello

    Thanks for the Info above I will go through the settings and see if I and find the differences.

    I posted in the UFPS forum a while back still no answer yet .

    Do you have any suggestions for any fps assets in the unity store that may provide a easier integration of the OVR camera rig or a better option to use for the FPS camera ?

    Thanks
     
  10. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    If you don't need weapons and a body, I've found that Unity's standard FirstPersonController works great in VR.

    Otherwise try importing only UFPS into a completely new, empty project. (Don't import the OVR camera rig package.) Then tick the Player Settings > Virtual Reality Supported checkbox and load up a scene with the Hero. It should work fine. If it does, try adding the VRMoveInHeadsetDirection script I posted above if you want to add that kind of behavior.
     
  11. yoolee

    yoolee

    Joined:
    Mar 3, 2016
    Posts:
    14
    Hello

    So I created a new project and imported UFPS . I clicked the VR setting the dk2 turns on fine but Im getting the fish eye effect.

    You said above to try the FirstPersonController if I don't need a weapon or body .

    What do you think would be the best option if I do need a weapon ? Do it without the body and maybe just the arm/arms?

    If that is the case any suggestions on the best way to do it ?

    Thanks
     
  12. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    I don't see the fish eye effect. Do you see the same thing with Unity's standard FirstPersonController?
     
  13. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    How long ago did you post on the UFPS (opsive forums)?
     
  14. yoolee

    yoolee

    Joined:
    Mar 3, 2016
    Posts:
    14
    I just deleted the hero from the scene and tried the FirstPersonController in the scene and it looks good no fish eye effect everything is the correct size . Would I be able to add the settings from the Hero to the FirstPersonController ? Everything but the fish eye effect of course.


    2/26/2016 forum
     
    Last edited: Mar 8, 2016
  15. yoolee

    yoolee

    Joined:
    Mar 3, 2016
    Posts:
    14
    Hello

    So after playing with it a bit I think its the FP_Camera script that is causing the fish eye effect. I would delete it but I need it for most the functions. Any idea what I can do to fix it ?

    Thanks
     
  16. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    You could try adjusting the camera's FOV (field of view).
     
  17. yoolee

    yoolee

    Joined:
    Mar 3, 2016
    Posts:
    14
    0l,..
    Hello

    I tried the FOV slider did not seem to effect the curve fish eye lens effect .

    If I use the FirstPersonController will i be able to apply all the scripts from the hero to the FirstPersonController and it will work as if Im using the hero ?
     
  18. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Sorry, I don't think so. They're quite different. But perhaps you can compare the FirstControllerController and UFPS cameras for differences that might explain the fish eye effect that you're seeing.
     
    Last edited: May 1, 2016
  19. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    Did anyone ever successfully get the guy to rotate properly depending on where you look? I cant get it working, im using OSVR, and above solution but he just spins around and around.