I have started cloning objects from a random range on my y axis.but they are getting destroyed before reaching the destroy position.Need help,really fast.
here is the generator script;
using UnityEngine;
using System.Collections;
public class generate : MonoBehaviour {
public GameObject clone,asteroid1;
public GameObject[] asc= new GameObject[3];
public float createrate = 0.5f;
private float nextcreate = 0.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
if (Time.time > nextcreate)
{
nextcreate = Time.time + 1.2f;
clone = Instantiate (asc[Random.Range(0,3)] , transform.position, transform.rotation) as GameObject;// create a duplicste of an object in the position of the "clone".
//Vector3 position = new Vector3(Random.Range(-10.0F, 10.0F), 0, Random.Range(-10.0F, 10.0F));
clone.transform.position = new Vector3 (10.875F, Random.Range (6.775F, -7.15F), 0);
}
}
}
Destroy Script;
using UnityEngine;
using System.Collections;
public class gameover : MonoBehaviour
{
public GameObject colt2;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter2D(Collision2D colt2)
{
if (colt2.gameObject.tag == "border")
{
Application.LoadLevel("game_over");
}
if (colt2.gameObject.tag == "ast")
{
Application.LoadLevel("game_over");
}
}
}