# Cast a ray from a camera

> Cast a ray and fetch information about what the ray hits.

The most common use of a Ray from the camera is to perform a [raycast](/engine/6000.6/script-reference/unityengine/physics/raycast.md) out into the scene. A raycast sends an imaginary "laser beam" along the ray from its origin until it hits a collider in the scene. Information is then returned about the object and the point that was hit in a [RaycastHit](/engine/6000.6/script-reference/unityengine/raycasthit.md) object. This is a very useful way to locate an object based on its onscreen image. For example, the object at the mouse position can be determined with the following code:

```lang-cs
using UnityEngine;
using System.Collections;

public class ExampleScript : MonoBehaviour {
	public Camera camera;

	void Start(){
		RaycastHit hit;
		Ray ray = camera.ScreenPointToRay(Input.mousePosition);
		
		if (Physics.Raycast(ray, out hit)) {
			Transform objectHit = hit.transform;
			
			// Do something with the object that was hit by the raycast.
		}
	}
}
```
