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);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you check if the left mouse button is clicked?

A

Input.GetMouseButtonDown(0)Returns boolean.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly