Raycasting*

(Camera) ScreenPointToRay()

Skapar en ray som utgÄr frÄn kamerans position och gÄr "igenom" en viss punkt pÄ skÀrmen.

Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);

Physics.Raycast()

RaycastHit hit;
Physics.Raycast(
  cameraObject.transform.position, 
  cameraObject.transform.forward, 
  out hit, 
  maxInteractionDistance);

Physics.Raycast(mouseRay, out RaycastHit hit)

Last updated