---
title: "Instantiate"
content_type: tutorial
url: "https://learn.unity.com/tutorial/instantiate-1?language=zh-cn"
language: zh-cn
difficulty: beginner
duration_minutes: 5
unity_version:
  - "2019.3"
  - "2019.2"
  - "2019.1"
  - "2018.4"
  - "2018.3"
  - "2018.2"
  - "2018.1"
  - "2017.4"
  - "2017.3"
  - "2017.2"
  - "2017.1"
  - "5.x"
  - "4.x"
supported_unity_versions:
  - name: "2019.3"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=2018.4"
  - name: "2018.3"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=2018.3"
  - name: "2018.2"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=2018.2"
  - name: "2018.1"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=2018.1"
  - name: "2017.4"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=2017.4"
  - name: "2017.3"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=2017.3"
  - name: "2017.2"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=2017.2"
  - name: "2017.1"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=2017.1"
  - name: "5.x"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=5.x"
  - name: "4.x"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn&version=4.x"
available_languages:
  - name: "en"
    url: "https://learn.unity.com/tutorial/instantiate.md?language=en"
  - name: "es"
    url: "https://learn.unity.com/tutorial/ejemplificar.md?language=es"
  - name: "ja"
    url: "https://learn.unity.com/tutorial/instantiate-insutansuhua.md?language=ja"
  - name: "ko"
    url: "https://learn.unity.com/tutorial/inseuteonseuhwa.md?language=ko"
  - name: "zh-cn"
    url: "https://learn.unity.com/tutorial/instantiate-1.md?language=zh-cn"
last_updated: "2026-08-04T14:22:35.000Z"
---

# Instantiate

在“初级编程”项目中学习如何使用 Instantiate 在运行时克隆预制件。

如何在运行期间使用 Instantiate 创建预制件的克隆体。

本教程包含在“[初级编程](https://learn.unity.com/project/chu-ji-bian-cheng?language=zh)”项目中。

上一教程：[类](https://learn.unity.com/tutorial/lei-l92v5?language=zh&projectId=5e3afd88edbc2a2998252c77)

下一教程：[数组](https://learn.unity.com/tutorial/shu-zu-7x?language=zh&projectId=5e3afd88edbc2a2998252c77)

## 1. Instantiate

[Video](https://connect-mediagw.unity.com/h1/20200206/videos/2b107ad8-4efc-4b45-a5b3-e02d4958fbc1_23_C__Instantiate_in_Unity!___Beginner_Scripting_Tutorial.mp4) ([Transcript (zh_cn)](https://connect-mediagw.unity.com/h1/20200206/931318d6-d0de-4d3b-90b9-762c1fbf536c_23_C__Instantiate_in_Unity____Beginner_Scripting_Tutorial___Chinese.vtt))

## **UsingInstantiate**

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

public class UsingInstantiate : MonoBehaviour
{
    public Rigidbody rocketPrefab;
    public Transform barrelEnd;
    
    
    void Update ()
    {
        if(Input.GetButtonDown("Fire1"))
        {
            Rigidbody rocketInstance;
            rocketInstance = Instantiate(rocketPrefab, barrelEnd.position, barrelEnd.rotation) as Rigidbody;
            rocketInstance.AddForce(barrelEnd.forward * 5000);
        }
    }
}
```

## **RocketDestruction**

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

public class RocketDestruction : MonoBehaviour
{
    void Start()
    {
        Destroy (gameObject, 1.5f);
    }
}
```
