title: C# unity Changing a variable using ray cast hit information
body: <p>The camera in this game has a target that can be changed by clicking on the other models and will then be the cameras focus, the script below is what I got so far however every time I click on an object in game the target just says none rather than any of the models.</p>
  
  <pre><code>Ray toMouse = Camera.main.ScreenPointToRay(Input.mousePosition);
  RaycastHit hitInfo;
  bool didHit = Physics.Raycast(toMouse, out hitInfo);
  
  if (didHit)
  {
      if (hitInfo.collider.tag == "Cell" &amp;&amp; Input.GetMouseButtonDown(0))
      {
          Debug.Log("Cell hit");
  
          target = hitInfo.transform.Find(gameObject.name);       
      }
  }
  </code></pre>