Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
craigsanto's avatar
craigsanto
Honored Guest
9 years ago

Porting a VR Asset

Hello everyone,

I'm new to VR Development, so I've been looking at the Unity and Oculus tutorials.

In the Unity VR Samples package, they have an item called a Selection Slider that I wanted to play with in my project. I just want the bar to fill up as the player hovers over it, without the need for any controller input. But there's a slight compatibility issue: using OVR's OVRPlayerController instead of UnityVR's Main Camera. I've been trying to solve this issue.

I know that there's some basic UI work in the Oculus Sample Framework, but copying all of the code over gets really ugly really quickly, and I don't feel like it's necessary.

Here's what I've done:

In UnityVR's SelectionSlider.cs:
  • Commented out all references to m_VRInput, as I don't want the player to have to press a button upon hovering over the slider
  • Added a call to HandleDown() at the end of HandleOver() - I could've just copied the two lines of code contained within, but I don't think this is a problem. I just want the bar to start filling up without the need for a button press.
The SelectionSlider events subscribe to the events of VRInteractiveItem, which themselves are straightforward. They are called when certain conditions are met by the VREyeRaycaster.
In UnityVR's VREyeRaycaster.cs:
  • Changed the line "[SerializeField] private Transform m_Camera;" to                                                                                       "[SerializeField] private Transform m_Camera = GameObject.Find("OVRPlayerController").transform.FindChild("CenterEyeAnchor");"                                                          
  • In other words, I've tried instantly shifting the Camera Transform to OVR's CenterEyeAnchor. But maybe that's being undone? Maybe I'm not doing that properly?
Other theories:
  • Does it have to do with how I set up my objects? The Sliders are currently the children of the objects they've been placed on.
  • Do I need to add colliders to the sliders manually? I wouldn't think so, but it's a possibility.
Other questions:
  • I wanted to add a crosshair/reticle to the game to make it easier to identify what exactly the player is looking at. UnityVR has a nice Reticle, but I'm sure I'd run into even more issues trying to port that over as well. OVR claims to have a crosshair in the documentation, but I can't access it in the code - it doesn't even seem to exist in the sample framework. What's going on, and what's my best option?
Thank you in advance for any responses. I know that digging through this stuff isn't exactly easy or fun.
Replies have been turned off for this discussion