- Home /
 
 
               Question by 
               Zypher · May 10, 2014 at 05:07 PM · 
                inputtapandroid iphone  
              
 
              How do I make an Object be destroyed just by tapping it?
So far the only gameObject I have is my GameController, and a sprite is attached to it. The GameController is responsible for spawning the sprite. What do I do if want to destroy the Sprite with a single tap. I'm building this app for Android.
Also I'm using Javascript.
               Comment
              
 
               
              Answer by JacobHockey13 · May 10, 2014 at 10:18 PM
 function OnMouseUpAsButton () {
 Destroy(gameObject);
 }
 
               This script should be attached to the gameObject. Also, the object needs to have a collider for the code to work.
I attached it to the GameController. How do I test if it works? I tried going to play mode and attempted to click the falling objects, but nothing happened.
Your answer