Raycast retuning info of hit object

Hi guys, I believe this is a very simplistic question, but I havent managed to find an answer to this one (at least one that I would understand).

My code:

  bool bIsButtonDown = Input.GetButton("Fire1");
    		if (bIsButtonDown)
    		{
    			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    			RaycastHit rch;// = new RaycastHit();
    			
    		}

After hitting an object I would like to get info (tag, or more prefferably name) of the object. My goal is very simple - three boxes in the scene, and I want something to happen when one of them is hit. After getting info it is probably just a simple “switch” but I can`t seem to understand how to get that info.

Being a noob, it will help me even if you can at least point me in the right direction. :slight_smile:

To do a raycast you can use Physics.Raycast() method:

bool bIsButtonDown = Input.GetButton("Fire1");
if (bIsButtonDown)
{
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    RaycastHit rch;

    if(Physics.Raycast(ray, out rch))
    {
       // do something
       // rch variable contains all the info about the object that is hit
    }
}