Hi folks,
i am working on a project, where birds are creating using prefab,
using UnityEngine;
using System.Collections;
public class birdGenerator : MonoBehaviour
{
public GameObject prefab;
public static float prevTime = Time.time;
public bool isChild;
void Start ()
{
}
Vector3 tempPos;
private Vector3 position = new Vector3 (0,0,0);
void Update ()
{
float myDelta = Time.time - prevTime;
if(myDelta >4.0f)
{
prevTime = Time.time;
Vector3 position = new Vector3(Random.Range(0.0f, 0.25f), 0.8f, Random.Range(0.0f, 10.0f));
GameObject BirdClone = Instantiate(prefab, position, Quaternion.identity) as GameObject;
BirdClone.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
isChild = prefab.transform.IsChildOf( GameObject.FindWithTag("model").transform);
BirdClone.transform.parent = GameObject.FindWithTag("model").transform;
}
}
}
when birds are behind the main camera,and not in the scene view , how to destroy unused birds from memory??? and bird is child of model( environment),
move with environment.
Thankx for advance.