유니티

오브젝트 삭제

Nhahan 2022. 6. 8. 23:37
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Delivery : MonoBehaviour
{
    private void OnCollisionEnter2D(Collision2D other) {
        Debug.Log("Hello");
    }

    public void OnTriggerEnter2D(Collider2D other) {
        if (other.tag == "Event") {
            Destroy(other.gameObject, 0.05f);
        }
    }
}

Destroy()를 쓰면 된다.

 

...

쉽다!

 

 

두 번째 인자인 0.05f는destroy하기 전까지의 딜레이이다.

딜레이 시간 안에 파괴 이펙트 같은 걸 넣으면 좋을 듯.

 

 

 

728x90