usingUnityEngine;usingSystem.Collections;publicclassStone:MonoBehaviour{publicGameObjectexplosion;//Creamos una variable, para establecer cuando la piedra moriraprivateconstfloatyDie=-30f;// Use this for initializationvoidStart(){}// Update is called once per framevoidUpdate(){//Si la posicion y llega a ser menor que el valor donde debe morir, destruimosif(transform.position.y<yDie){//gameObject es el propio object asociado.Destroy(gameObject);}}voidOnMouseDown(){Instantiate(explosion,transform.position,Quaternion.identity);//Cuando alguien pulsa sobre la piedraDestroy(gameObject);}}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.