I am new to unity and VR. I have been using google cardboard SDK to create VR apps in unity and am stuck at gazetimer. I want to trigger an action only if the user looks at any object for 3secs but have not been able to do so. Please help
相关问题
- Unity - Get Random Color at Spawning
- Unity3D WebGL Headless not rendering
- How to fix NDK build error for HelloCardboard samp
- Unity3D loading resources after build
- Load Image from Stream/StreamReader to Image OR Ra
相关文章
- Programmatically setting and saving the icon assoc
- Omnisharp in VS Code produces a lot of warnings ab
- Call non-static methods on custom Unity Android Pl
- How can a game created in Unity can run on an Andr
- How to add Persistent Listener to Button.onClick e
- Placing an object in front of the camera
- Connecting Unity3d Android application to ActiveMQ
- How to mimic HoloLens 2 hand tracking wIth Windows
Please see a similar question and answer here Use Gaze Input duration to select UI text in Google Cardboard
In summary, create a script to time the gaze, by cumulatively adding
Time.deltaTime
on each frame when the object is gazed at. When gaze time hits a pre-specified duration, trigger the button'sOnClick
event.On the object, activate the script's gaze timing functions using event triggers
Pointer Enter
andPointer Exit
. See screenshot:VR Camera usually contains a main camera and eye cameras (right and left). Since Main camera's center point will always be the center of the eyes of the user's point of view, you could use
Raycast
from itstransform.position
to itstransform.forward
and check whether it hits your object. Then simply add a timer which will call the action after it reaches the duration you have set.For example:
Hope you get the idea.