unitry raycast

Code Example - unitry raycast

                
                        using UnityEngine;
//This will cast a raycast from the mouse to the world
public class ExampleClass : MonoBehaviour
{
    void FixedUpdate()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, 100))
            print("Object hit!");
    }
}