指定した時間経過後に自爆
![3247777d 4e18 4948 89db 05d7a92af524](https://codegenius.org/uploads/slide/image/2179/3247777d-4e18-4948-89db-05d7a92af524.jpeg)
指定時間経過後に破壊する
using UnityEngine;
using System.Collections;
public class SelfDestroy : MonoBehaviour {
public GameObject effectPrefab;
void Start () {
Invoke("DestroyShell", 1.5f);
}
void DestroyShell(){
Destroy(gameObject);
Instantiate(effectPrefab, transform.position, Quaternion.identity);
}
}
Unity Code Memo
他のコースを見る![3247777d 4e18 4948 89db 05d7a92af524](https://codegenius.org/uploads/slide/image/2179/3247777d-4e18-4948-89db-05d7a92af524.jpeg)
指定時間経過後に破壊する
using UnityEngine;
using System.Collections;
public class SelfDestroy : MonoBehaviour {
public GameObject effectPrefab;
void Start () {
Invoke("DestroyShell", 1.5f);
}
void DestroyShell(){
Destroy(gameObject);
Instantiate(effectPrefab, transform.position, Quaternion.identity);
}
}
指定した時間経過後に自爆