Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // Do a raycast into the world based on the user's
  2. // head position and orientation.
  3. var headPosition = Camera.main.transform.position;
  4. var gazeDirection = Camera.main.transform.forward;
  5.  
  6. RaycastHit hitInfo;
  7. Ray ray;
  8. Camera c = Camera.main;
  9.  
  10. ray = c.ScreenPointToRay(headPosition);
  11.  
  12. if (Physics.Raycast(headPosition, gazeDirection, out hitInfo))
  13. {
  14.  
  15.  
  16. // If the raycast hit a hologram...
  17. objHit = hitInfo.transform;
  18.  
  19. // Move the cursor to the point where the raycast hit.
  20. this.transform.position = hitInfo.point;
  21.  
  22. // Rotate the cursor to hug the surface of the hologram.
  23. this.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement