Look away from object and it changes

Hi all,

Trying to do something like sightline the chair if you know it.
Look at an object say a lamp, look away and when you look back it’s a different lamp.
I’m thinking gaze detection but not sure how to implement this.

Any ideas?

thanks

What about if you raycast out of your viewpoint and then detect that you hit an object outside of the view? You would have to estimate where that point is, but basically put invisible objects to collide with your constantly firing raycast and when it hits them then that triggers the object to change.

Actually what would probably be easier is to actually literally have an object projecting out from you head. Just make it invisible.

For a real world example, say you have a big broom handle attached to your face so it points straight out. As you turn your head far enough to one side, you bump into a big lever that you will knock/activate. When you turn your head back you notice that the lever did something.

So in the game, attach an actual object with a collider to the VR head. As your player turns their head, you will have another strategically positions collider that it will bump in to. This is placed at a distance that the player would have turned their head far enough to not see the changing object.

Monobehavior has these message handlers you can inherit:

So you could do something as simple as attach this script to game object model you want to switch:

using UnityEngine;
public class NoGazeSwapper : MonoBehaviour
{
    private void OnBecameInvisible()
    {
        //  YOUR CODE TO SWAP MODEL MESH HERE
    }
}