Raycasting is an incredibly useful tool in game development. In Unity, raycasting is as easy as Physics.Raycast. There are a lot of overloads for this method, which you can find in the Unity API (https://docs.unity3d.com/ScriptReference/Physics.Raycast.html), but the basic result is to shoot a ray in a direction and return something that was hit. What you do with that information once you have it is up to you. There are almost endless possibilities, and Unity makes finding the right one for your situation very easy.