Raycasting Flashcards
1
Q
How do you make a ray that starts at the camera and from the centre of the screen?
A
Camera camera = GetComponent();Vector3 point = new Vector3(camera.pixelWidth/2, camera.pixelHeight/2, 0);camera.ScreenPointToRay(point);
2
Q
How do you raycast with a given RaycastHit hit and Raycast Ray and print the location to the log?
A
if (Physics.Raycast(ray, out hit)) { Debug.Log(hit.point)}
3
Q
How do you check if the left mouse button is clicked?
A
Input.GetMouseButtonDown(0)Returns boolean.
4
Q
What are rays and what is raycasting?
A
Rays are invisible lines that start at some origin and extends in a specific direction.Raycasting finds out what intersects that ray.