I am trying to delete the object on which the mouse is clicked. I am making a 2D game using the new Unity3D 4.3. Here is the code I\'m using
void Update () {
You've to attach a mesh collider(any collider) with your object first to enter the inner If. Then,
Destroy(hit.collider.gameObject);
will simply do the job.
There's might be an other work around here.
void Update () {
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray,out hit))
{
if(Input.GetMouseButtonDown(0))
{
isHit = false;
Destroy(hit.collider.gameObject);
}
}
}