오브젝트에 물리적인 연산을 부여
옵션
- Mass : 질량
- Drag : 공기저항
- Angular Drag : 공기저항(회전)
- Use Gravity : true일 때 중력 적용
- Is Kinematic : true일 때 물리 영향 받지 않음(중력도)
- Interpolate : 얼마나 부드럽게 물리를 적용할지
- Collision Detection : 충돌검사를 얼마나 촘촘하게 할지
- Constraints : 포지션과 로테이션에 대한 잠금 (잠금된 축은 물리영향 받지 않음)
private void OnTriggerEnter(Collider other)
{
Debug.Log(other.name + " 트리거 충돌");
}
private void OnCollisionEnter(Collision collision)
{
Debug.Log(collision.gameObject.name + " 콜리전 충돌");
}
private void OnTriggerStay(Collider other)
private void OnTriggerExit(Collider other)
Destroy(gameObject);
: 자기자신 없어짐Destroy(collision.gameObject);
: 부딪힌 오브젝트 없어짐Destroy(collision);
: 부딪힌 물체의 콜라이더만 없어짐if (collision.gameObject.tag == "wall")
{
collision.gameObject.GetComponent<wall>().ReduceDurability(1);
}
tag가 wall인 경우에만 실행
gameObject.GetComponent<wall>
에서 wall
은 태그가 아니고 충돌한 object가 가지고 있는 스크립트(ReduceDurability()
라는 함수를 포함한)이다.
if(coillision.gameObject<wall>()!=null)