---
title: "Destroy"
content_type: tutorial
url: "https://learn.unity.com/tutorial/destroy-i?language=en"
language: en
difficulty: beginner
duration_minutes: 5
unity_version:
  - "2021.3"
supported_unity_versions:
  - name: "2021.3"
    url: "https://learn.unity.com/tutorial/destroy-i.md?language=en&version=2021.3"
available_languages:
  - name: "en"
    url: "https://learn.unity.com/tutorial/destroy-i.md?language=en"
  - name: "es"
    url: "https://learn.unity.com/tutorial/destruir.md?language=es"
  - name: "ja"
    url: "https://learn.unity.com/tutorial/destroy-guan-shu.md?language=ja"
  - name: "ko"
    url: "https://learn.unity.com/tutorial/destroy-p.md?language=ko"
  - name: "zh-cn"
    url: "https://learn.unity.com/tutorial/destroy-n.md?language=zh-cn"
last_updated: "2026-10-07T22:10:21.000Z"
---

# Destroy

Discover how to use the Destroy() function to remove GameObjects and components at runtime.

How to use the Destroy() function to remove GameObjects and Components at runtime.

Previous: [Linear Interpolation](https://learn.unity.com/tutorial/linear-interpolation?projectId=5c8920b4edbc2a113b6bc26a)

Next: [GetButton and GetKey](https://learn.unity.com/tutorial/getbutton-and-getkey?projectId=5c8920b4edbc2a113b6bc26a)

## 1. Destroy

[Video](https://connect-mediagw.unity.com/h1/20220104/videos/0907b47e-e77d-49bf-a790-75887d6e5138_U_Beginner_14_Destroy.mp4)

## **DestroyBasic**

```csharp
using UnityEngine;
using System.Collections;

public class DestroyBasic : MonoBehaviour
{
    void Update ()
    {
        if(Input.GetKey(KeyCode.Space))
        {
            Destroy(gameObject);
        }
    }
}
```

## **DestroyOther**

```csharp
using UnityEngine;
using System.Collections;

public class DestroyOther : MonoBehaviour
{
    public GameObject other;
    
    
    void Update ()
    {
        if(Input.GetKey(KeyCode.Space))
        {
            Destroy(other);
        }
    }
}
```

## **DestroyComponent**

```csharp
using UnityEngine;
using System.Collections;

public class DestroyComponent : MonoBehaviour
{
    void Update ()
    {
        if(Input.GetKey(KeyCode.Space))
        {
            Destroy(GetComponent<MeshRenderer>());
        }
    }
}
```
