using System.Collections; using System.Collections.Generic; using UnityEngine; public class RemoveBullet : MonoBehaviour { [SerializeField] private GameObject sparkEffect; void Start() { sparkEffect = Resources.Load("SparksEffect"); } void OnCollisionEnter(Collision coll) { // Garbage Collection // if (coll.collider.tag == "BULLET") if (coll.collider.CompareTag("BULLET")) { Destroy(coll.gameObject); // 충돌 정보 ContactPoint cp = coll.GetContact(0); // 충돌 지점(좌표) Vector3 pos = cp.point; // 충돌 지점의 법선 벡터 Vector3 normal = -cp.normal; // 벡터를 Quaternion 타입으로 변환 Quaternion rot = Quaternion.LookRotation(normal); // 스파크 생성 Instantiate(sparkEffect, pos, rot); } } // 충돌 콜백함수 /* # Collider의 Is Trigger 언체크 OnCollisionEnter --- 1 OnCollisionStay --- n OnCollisionExit --- 1 # Collider의 Is Trigger 체크 OnTriggerEnter --- 1 OnTriggerStay --- n OnTriggerExit --- 1 */ }