LoginSignup
3
4

More than 5 years have passed since last update.

指定した時間経過したらGameObjectを消すスクリプト

Last updated at Posted at 2018-01-13

前提条件

Unityのバージョン:2017.2.0f3
使用した言語:C#
筆者のプログラミング能力:チンパンジー

コード

    // 引数の宣言
    // Destroyする時間を指定する
    public float time = 2;

    // DestoryしたいGameObject(基本はアタッチされたもの)
    public GameObject gameObject;

    // Use this for initialization
    void Start()
    {
        // Destory
        Destroy(gameObject, time);
    }

    // Update is called once per frame
    void Update()
    {

    }

内容

一定時間後にGameObjectをDestroyするだけ
プレハブなどにアタッチして、呼び出した後に消したい時とかに使えそう。

変数

GameObject gemeObject

消したいGameObject

float time

何秒後にgameObjectを消すか

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4