Android OnTouch only when on object

Hi,

I’m new to Unity and am trying to use it to create a game for Android (or other platforms but focusing on Android to start) and I was wondering how I can add a touch listener for an object (just using simple cubes right now). In the Update() if I add some similar to seen below I can get things to happen on or around the object when the screen is touched but I only want this when it is on top of the object not just anytime.

if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
{
  rigidbody.AddExplosionForce(forceAmount, transform.position, 25.0f, 1.0f);
}

So my question is how can I have this happen only when the user actually touches in the cube and not anywhere on the screen. Is there a good way or do I just need to check the position of the cube vs the position of the touch? Thanks in advance,

Jason

Fire a ray into the scene at your mouse position and see if it intersects the desired object.

RaycastHit hitInfo;
Ray r = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(r, out hitInfo))
{
   if(hitInfo.collider = yourObject.collider)
   {
      rigidbody.AddExplosionForce(forceAmount, transform.position, 25.0f, 1.0f);
   }
}

See http://unity3d.com/support/documentation/ScriptReference/Physics.Raycast.html

if(hitInfo.collider = yourObject.collider)

== is 2
if(hitInfo.collider == yourObject.collider)