Creating a Trigger for Looking at something

Hello,

A potential client wants a demo that involves putting you in the center of live action 360 video, but making it so that, when you look at certain parts of the video, motion graphics pop up. Now, I can do that animation work myself as separate actions, but the issue is that I have no idea how to create a script that tells an action to happen when you look at something, then go away when you’re not viewing it. Example (since I don’t know what their video is), you look at a car, data pops up about that car. Not sure it has to be moving or anything, I think even if the object on screen is moving, the data can be stationary. I just need it to pop up when something is in frame. Anyone have a JS or C# script for this?

Thanks!

You could do it with raycasts from the HMD forward, if it hits whatever you expect it to be hitting then trigger whatever. You can’t actually tell if the person is “looking” at it (unless you’re using some HMD that has eye detection somehow), the best you can really do is if they’re facing it.

So just look up some raycast tutorial, I guess. Shouldn’t be too difficult.

Another way to do this, is to place a UI element (eg. Button) where the car is and the OnPointerEnter function provided by UnityEngine.EventSystems and the IPointerEnterHandler interface.

Please have a look at the scripting API → http://docs.unity3d.com/ScriptReference/UI.Selectable.OnPointerEnter.htm

These are great suggestions, guys! Thanks! I’ll give them both a try!

Also my screen name is different for some odd reason, but, uh, I’m the guy that started this thread.