Snippets

David Fraj Destruir un objeto del juego, al caer

Created by David Fraj

File stone.cs Added

  • Ignore whitespace
  • Hide word diff
+using UnityEngine;
+using System.Collections;
+
+public class Stone : MonoBehaviour {
+
+	//Creamos una variable, para establecer cuando la piedra morira
+	private const float yDie=-30f;
+
+
+	// Use this for initialization
+	void Start () {
+	
+	}
+	
+	// Update is called once per frame
+	void Update () {
+		//Si la posicion y llega a ser menor que el valor donde debe morir, destruimos
+		if(transform.position.y < yDie){
+			//gameObject es el propio object asociado.
+			Destroy (gameObject);
+		}
+	}
+}
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.