Forum Discussion

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

Mouse Events and delta position issues on GearVR with Unity

Heya, I'm not really sure if this should be in the Unity board or the gear VR board, but hopefully I picked a suitable place!

I've been using the OnMouseEnter()/Exit()/Hover() Messages for when I am looking at objects in the gear VR project I am working, but I've noticed some issues with this approach, and am wondering if anyone has any ideas on what I could do to resolve them. So first here's the desired behavior. I wanted to make something where if you look at the object and tap, the object does some kind of action, If you do a swipe on the track pad it will rotate the gameboard you are looking at (This introduces the problem). This swipe however also changes the mousepointers position. This almost isn't a problem, as when you tap, it re-centers the mouseposition and you do end up interacting with what you are looking at, but we also wanted to have feedback for when you are looking at something and have not clicked yet (an outline around the object). With the mouse position not being in the center until you tap again, all the hover animations and effects don't trigger when they are in the center of your view, they trigger when they are at your mouses offset.

One of the steps I've taken that I thought was going to be in the direction of fixing this issue was setting the lockstate
Cursor.lockState = CursorLockMode.Locked;

The documentation says that should lock the mouse in the center. It does so for the mouse in the editor, but the gear VR mouse still has free movement. So one question I have is will this lock the Gears mouse pointer in the future, is that planned or is this something I will never be able to rely on? Unity doesn't seem to support manually setting the mouse position, so as far as Mouse events go I'm not really sure what to do about this.

Another approach was to ditch using the on mouse stuff all together and fire a ray from the camera's center eye anchor forward and send messages to its targets. This worked for anything on the gameboard, but we are also using worldspace Canvases for the UI, and the UI button components don't react as they use that graphics raycaster thing and don't actually have box colliders. I could put box colliders on all the ui, and stop using the Button and Event trigger stuff but it would be a real hassle as there's a lot of ui to update. I'm really curious if anyone has any better ideas.

There is one final note I wanted to make/ask about. You seem to be able to get the deltaPosition from the Input Axis "Mouse X"( or Y), Which is pretty handy, but if you release you finger and then press and drag again (Even if you start from the same location you released at) it seems to do that thing I mentioned above where it resets the mouse position to be the center of the screen, leading to a huge jump in mouse delta. Is that the intended/Is this to be desired? I suppose it could be worked around by just not doing actions that are based on the delta when the mouse button state is down, but that just does not seem ideal.

2 Replies

Replies have been turned off for this discussion
  • Hi,

    You can use that to perform look based UI on Gear VR for both Canvas UI and 3D Game Objects.

    Check out my blog post here to find our how:

    http://talesfromtherift.com/vr-gaze-input/


    You can then keep track of which object(s) is selected.

    Then directly use mouse input from the GearVR trackpad to handle swiping and tapping commands.
  • Oh nice! I ended up just creating a copy of the standalone input module and making some modifications to it to keep the mouse position event it used always in the center of the screen, and firing a raycast that would send messages to anything you look at for things in the scene. I was coming back to post my solution but... I'm thinking yours looks like it has a bit more functionality to it/is cleaner so I'll just leave it at that, I'm probably going to end up switching over to this. Thanks a lot!