Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Do a raycast into the world based on the user's
- // head position and orientation.
- var headPosition = Camera.main.transform.position;
- var gazeDirection = Camera.main.transform.forward;
- RaycastHit hitInfo;
- Ray ray;
- Camera c = Camera.main;
- ray = c.ScreenPointToRay(headPosition);
- if (Physics.Raycast(headPosition, gazeDirection, out hitInfo))
- {
- // If the raycast hit a hologram...
- objHit = hitInfo.transform;
- // Move the cursor to the point where the raycast hit.
- this.transform.position = hitInfo.point;
- // Rotate the cursor to hug the surface of the hologram.
- this.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement