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
'유니티' 카테고리의 다른 글
회전 컨트롤하기 (0) | 2022.06.11 |
---|---|
Mac에서 에셋 zip파일 잘 import하기 (0) | 2022.06.09 |
Tag를 이용해서 Collision(Trigger) 구현 (0) | 2022.06.08 |
카메라(시점) 따라가기 (0) | 2022.06.08 |
[2D] Collision과 Trigger (0) | 2022.06.08 |
댓글