Hi,
I am trying to make a game where an object falls from the top(out of view) to the bottom of the screen and i am trying to implement that when the player touches the screen the falling object is removed from the game and in turn adds a point to the player’s score.
I have created the gameObject as a prefab and added the following code but nothing happens when i click on the object;
public class OnClickDestroy : MonoBehaviour {
void OnMouseDown()
{
Destroy (gameObject);
}
}
i added this code into the inspector for the prefab, but i woundered if the code is not working because i am using ‘Destroy (gameObject);’ in the code and the item falling is a prefab?
thank you