Forum Discussion

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

For mouse events

Hai all,
I am recently started working for Oculus VR with unity3d. An d i implemented in my first person related games also. Controlls are working good but i struggled with blur quality and texture flickering and head bobbing. An d more over my big issue is mouse event functions. Normal mouse event functions are not working with unity. Is this statement correct or not?
Please help me.
Thanx in advance.

7 Replies

Replies have been turned off for this discussion
  • drash's avatar
    drash
    Heroic Explorer
    You might have to be a little more specific with your question, but yes mouse input works just fine in Unity as far as I can tell. :)
  • With the Oculus plugin, you can still write code that responds to mouse movement (Input.mousePosition/Input.GetAxis(..)) or button up/down changes (Input.GetMouseButtonDown/Up(..)).

    Raycasting from the mouse is more complicated, but I wouldn't recommend doing it anyway. First, you would have to convert the mouse position to a ray in world space. That is non-trivial because each eye image is distorted by a lens correction effect and the mouse can only be over one eye image at a time. So Unity's Camera.ScreenPointToRay(..) function wouldn't be enough. You might be able to build a look-up table to convert distorted screen points into world points...

    It usually works much better to just raycast along the user's "gaze" direction. The ray origin is the "center" eye, or the average of the left and right camera positions and the direction is parallel to both of their forward vectors. Does this work for your use case?
  • Thanx for giving replies Mr. vrdaveb and Mr.drash,
    But my already made for PC now i implemented for OCULUS VR technology in side that project, every thing is working fine accept mouse events because of in that project i used only raycast hit , by this cause mouse events are not working in oculusvr. What can i do . Please help me guyz.
  • I haven't tried this, since gaze direction works so well. But one thing you could do is set up a dummy camera that covers the union of the two undistorted eyes. Put it halfway between the two eyes with the same vertical field-of-view as either eye camera. Then you can keep calling "Camera.ScreenPointToRay(Input.mousePosition);" with your dummy camera instead of Camera.main, etc. Make sure Camera.depth is lower than the OVR cameras' and its culling mask and clear flags are turned off to save performance. You'll need to draw your own 3D mouse cursor. You could use a sprite that always faces opposite the viewing direction. Its position would be dummyCamera.ScreenToWorldPoint(Input.mousePosition + mouseDepth * Vector3.forward). To cover the whole visible area, make the dummy camera's horizontal field of view wide enough that its FOV covers the union of the left and right eyes at mouseDepth: 2 * atan( tan(0.5 * eyeFovX) + 0.5 * IPD / mouseDepth ). Let me know if that works for you.
  • Thanx for giving replies with good suggetions , any way i found solution for that , even used raycasting also. Now mouse events are woking properly with raycast function. I feel very happy. And more over i have only one issue like quality (textures and unity text) .My textures and text are not clearly visible. What can i do for that. Please give a solution for me.
  • "ganeshdm" wrote:
    My textures and text are not clearly visible. What can i do for that. Please give a solution for me.

    This was covered in another thread: https://developer.oculusvr.com/forums/viewtopic.php?f=37&t=8950&p=119124#p119124

    If you are having trouble enabling the camera texture, I would suggest anti-aliasing. If you use forward rendering, I'd recommend multisampling. If you use deferred rendering, the options are more limited. You could use the Unity Pro Image Effect "Antialiasing as Post-Effect".