cancel
Showing results for 
Search instead for 
Did you mean: 

Unity mouse implementation

Stankiem
Honored Guest
I am trying to implement Oculus into my game. For the life of me, I cannot find a good tutorial on implementing a mouse in Unity3d within VR. I need a mouse to be able to interact with a complex UI and the world environment. I can place the UI on a plane in front of the player no problem and it get it to show up as expected, but beyond that, I am lost on how to design and implement a good input scheme. Something similar to half life or Minecrift would work well for the game.

Thanks much!
6 REPLIES 6

cybereality
Grand Champion
The cursor should be it's own object, that can be drawn in 3D space (not just plastered on the screen). The depth should be at the depth of the object it is on top of. Think of it as a laser pointer. You can do this with a ray cast from the center between the eyes into the scene. Hope that helps.

Stankiem
Honored Guest
Thanks Cyber, surprised Oculus / another dev hasen't already made a good script for this on the asset store with keyhole and other configurable settings. Seems like there must be hundreds of people who have coded the same thing already.. 😞 But then again, maybe it's too specialized per application to really be that useful.

cybereality
Grand Champion
Yes, this is something that I think would be very useful for developers.

Maybe I'll see if I can hack something together as an example.

enzedda
Explorer
"cybereality" wrote:
Yes, this is something that I think would be very useful for developers.

Maybe I'll see if I can hack something together as an example.


I hope you do!
I'll buy it because it would be so useful.
My attempts at raycasting are so intermittent and random!
If it's below $50 I'll certainly be interested indeed.
So please, if you can. 🙂

Stankiem
Honored Guest
I just realized OVRCrosshair exists.. Hit "C" while using the OVRPlayerController and it brings up a crosshair with a keyhole etc... This is nice and has almost the exact behavior I want, a little tweaking will make it work very well. However... It's all a private class which leads me to believe that I would be able to access it's raytrace hit result somewhere? But it doesn't seem to even have a function to do this?

Also, how would I use a solution like this with NGUI? I would need NGUI to recognize mouse clicks, drags, drops etc... Since it's only a raytrace interacting with the colliders and not the actual mouse, I don't think this will work.

Sorry, searches have all come up dry on these topics.

djinni69
Honored Guest
Just wanted to let you guys know that I did write a script package for this very problem, and it's available on the Unity Asset Store for $5. The cursor is a game object that has presence in the scene, and depending on the shape you choose for the 3D representation (it can be anything, just drop a prefab on the proper script variable) you can also determine the curve of a mesh. Kinda cool for rock climbing games and what not 🙂

https://www.assetstore.unity3d.com/en/#!/content/11944

Here's how to set it up in the latest Tuscany demo:
https://www.youtube.com/watch?v=kOqoqB_RUfY