xxxxxxxxxx
// To remove a GameObject use the function 'Destroy()'
Destroy(gameObject);
xxxxxxxxxx
using UnityEngine;
public class ExampleScript : MonoBehaviour
{
public GameObject objectToDestroy;
void Start()
{
// Destroy the GameObject after 3 seconds
Destroy(objectToDestroy, 3f);
}
}