Bool
2023. 3. 7. 11:50ㆍ개인적인 공부/Unity
참, 거짓 if와 함께 사용한다.
bool hasPackage;
private void Start() {
Debug.Log(hasPackage);
}
public class Delivery : MonoBehaviour
{
// 어떠한 것과 부딪히면 무엇에 부딪혔는가에 대한 정보를 얻는다.
bool hasPackage;
private void Start() {
Debug.Log(hasPackage);
}
void OnCollisionEnter2D(Collision2D other)
{
Debug.Log("빼-앰~!!");
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Package")
{
Debug.Log("Package picked up");
hasPackage = true;
}
if(other.tag == "Customer" && hasPackage)
{
Debug.Log("Delivered package");
hasPackage = false;
}
}
}
'개인적인 공부 > Unity' 카테고리의 다른 글
Get Component (0) | 2023.03.08 |
---|---|
객체삭제? Destroy() (0) | 2023.03.08 |
if 구문 (0) | 2023.03.07 |
단순 카메라 팔로우 (0) | 2023.01.23 |
OnTriggerEnter2D() (0) | 2023.01.16 |