title: How to Make Raycast Effect Named GameObject Only
body: <p>In my current(Unity 3.3 IOS)project I have a character walking across a bridge. If the character falls off 
  the bridge he is to fall into a fiery river and explode. The problem is when he's on the bridge the Raycast reads the rigidbody on the bridge and he immediately explodes.  If I reposition him in the scene window to an open air position, the gravity causes him to fall into the river and explode as planned. I added the following line of code to designate only destroy if the raycast hits the "plane".  It doesn't work.</p>
  
  
  
  <pre class="lang-c# prettyprint-override"><code>if(hit.collider.gameObject.name == "plane");
  </code></pre>
  
  <p>The character does not get destroyed on the bridge or when he hits the plane/fiery river.</p>
  
  <p>There are several bridges and buildings he will be walking into, so I only want him to be destroyed/explode if the raycast hits the plane.  </p>
  
  <p><strong>Can anyone tell me why my code isn't working or how to correct it?</strong></p>
  
  <p>Here is my complete Raycast code.</p>
  
  <pre class="lang-c# prettyprint-override"><code>var explosion : Transform;
  var point : Vector3;
  var explosionRotation : Quaternion;
  
  function Update()
  {
      var hit :RaycastHit;
      var dwn = transform.TransformDirection(Vector3.down);
      if (Physics.Raycast(this.transform.position,dwn,hit,3))           
          if (hit.collider.gameObject.name == "plane")
          {
              point = hit.point;
              explosionRotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
              Explode();
          }
  }
  
  function Explode()
  {
      Destroy(this.gameObject);
      var instanExplosion = Instantiate(explosion, point, explosionRotation);
  }
  </code></pre>