I want to create objects for few seconds after colliding it. Could you tell me how to destroy clones after few seconds after colliding and creating them? I’m using C# scripts.
Ps. I’m thinking about something like destroying clones 5 seconds after creating them. (sorry if i made mistakes i’m not from USA or England and I don’t know English Well… )
using UnityEngine;
using System.Collections;
public class Object_1 : MonoBehaviour {
public Transform prefab;
void OnTriggerEnter(Collider anotherobject)
{
Instantiate(prefab, new Vector3(208.353F, -81.55669F, 179.8901F),new Quaternion(90, 0 ,0, 90));
Instantiate(prefab, new Vector3(208.353F, -81.55669F, 175.8901F),new Quaternion(90, 0 ,0, 90));
Instantiate(prefab, new Vector3(208.353F, -81.55669F, 173.8901F),new Quaternion(90, 0 ,0, 90));
}
}