Created
August 1, 2019 09:46
-
-
Save knightcube/f907df367441515e2692dcf43f19aa55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class SimpleGazeCursor : MonoBehaviour | |
{ | |
public Camera viewCamera; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
UpdateCursor(); | |
} | |
private void UpdateCursor() | |
{ | |
// Create a gaze ray pointing forward from the camera | |
Ray ray = new Ray(viewCamera.transform.position, viewCamera.transform.rotation * Vector3.forward); | |
RaycastHit hit; | |
if (Physics.Raycast(ray, out hit, Mathf.Infinity)) | |
{ | |
Debug.Log("Gazing at "+hit.transform.name); | |
} | |
else | |
{ | |
Debug.Log("Gazing at nothing"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment