백지부터 시작하는 이세계 코딩 생활
CompareTag 비교 본문
other.gameObject.CompareTag("Player"
각각의 Object들에 할당되어있는 Tag값을 확인할 때 사용한다.
ex) 확인한 태그의 값에 따라 특정 이벤트를 구현한다.
// Immediate death trigger.
// Destroys any colliders that enter the trigger, if they are tagged player.
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
Destroy(other.gameObject);
}
}
}
Ref.
2 docs.unity3d.com/ScriptReference/Component.CompareTag.html
'백지부터 시작하는 이세계 유니티 생활 since 2020' 카테고리의 다른 글
ScreenToWorldPoint (1) | 2021.01.12 |
---|---|
Invoke, InvokeRepeating (0) | 2021.01.11 |
Preserve Aspect (0) | 2021.01.05 |
Delegate 와 Event (키워드) (0) | 2020.12.31 |
Animation State (Any State) (2) | 2020.12.29 |
Comments