반응형
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Example : MonoBehaviour
{
public void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Player")
{
Debug.Log("플레이어와 접촉 시작");
}
}
public void OnTriggerStay(Collider other)
{
if (other.gameObject.tag == "Player")
{
Debug.Log("3D 플레이어와 접촉중");
}
}
public void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Player")
{
Debug.Log("3D 플레이어와 접촉 끝");
}
}
public void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
Debug.Log("2D 플레이어와 접촉 시작");
}
}
public void OnTriggerStay2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
Debug.Log("2D 플레이어와 접촉 중");
}
}
public void OnTriggerExit2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
Debug.Log("2D 플레이어와 접촉 끝");
}
}
}
반응형