Vive highlight button by looking and select using controllers trigger.

Hi all,

What is the best way to do this? The intention is to highlight gameobjects by looking at it with the headset and GUI buttons and hit trigger to select.

Sending out a raycast from the headset’s camera? Any ideas?

To highlight UI buttons makes sure the highlight option in the inspector is not white. Although this doesn’t centre on straiht its just a tad top right.

I have not got to the select highlighted button or gameobject yet with right trigger still getting my head around Vive controller etc. -__-

Camera camera;

	// Use this for initialization
	void Start () {

		camera = GetComponent<Camera> ();
	}
	
	// Update is called once per frame
	void Update () {

		Ray ray = camera.ViewportPointToRay(new Vector3(0.0F, 0.0F, 0));
		RaycastHit hit;

	}
}

For GameObjects I used shaders the code goes like this:

        Camera camera;
	private int currentColor,length;
	public Renderer rend;
	public bool isHighlighted = false;
	public Shader unlitShader;
	public Shader litShader;

	// Use this for initialization
	void Start () {

		camera = GetComponent<Camera> ();
	
	}
	
	// Update is called once per frame
	void Update () {

		Ray ray = camera.ViewportPointToRay(new Vector3(0.0F, 0.0F, 0));
		RaycastHit hit;
		if (Physics.Raycast (ray, out hit)) {

			if (!isHighlighted) {

				rend.material.shader = litShader;

			} else {
				
				rend.material.shader = unlitShader; 

			}
		}

	}
}