Skip to content

Instantly share code, notes, and snippets.

@OutlawGameTools
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OutlawGameTools/44e0a066caf33d8522c9 to your computer and use it in GitHub Desktop.
Save OutlawGameTools/44e0a066caf33d8522c9 to your computer and use it in GitHub Desktop.
CS109 - Destroy the game object when clicked on. Game object must have a collider component.
#pragma strict
function OnMouseDown ()
{
if (gameObject.transform.position.y > -2 && gameObject.transform.position.y < 4)
{
GameData.numGrabbed++;
GameData.DisplayScore();
Destroy(gameObject);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment