Hello
My problem is:
I am making a stacker type of game in which object appears in the top-center of the screen, then player must catch it and put it on the platform (not throw it). I want that object to be destroyed by colliding with the platform, if player will not catch it (using mouse or a finger). However, even after catching it, I want that object to be destroyed if it will fall from high. Now the player can destroy it by hitting Space key, but I want it the way I just explained.
There are 2 prefabs:
- the object itself
- fragments of that object (after destroying)
Script that destroys this object (named “example” here) to fragments:
#pragma strict
var examplePrefab : GameObject;
var examplePos : Vector3;
var fragmentLocation : Vector3;
function Update () {
examplePos = this.gameObject.transform.position;
fragmentLocation = new Vector3(examplePos.x + 0.7f, examplePos.y + 0.7f, examplePos.z);
if(Input.GetKeyDown(KeyCode.Space)){
Destroy(this.gameObject);
Instantiate(examplePrefab, fragmentLocation, examplePrefab.transform.rotation);
}
}
I would be grateful for any help.