유니티 땅(ground) 체크하기
1. 캐릭터 컨트롤러 컴포넌트를 사용해서 검사 하는 방법.
isGrounded = characterController.isGrounded;
2. 피직스.체크스피어로 작은 구를 만들어서 구가 땅에 닿았는지 확인
- 땅 오브젝트를 ground 레이어로 설정하고 groundMask도 ground로 설정.
- 기즈모를 그려서 구의 크기를 조절해가면서 바닥 체크
[Header("Ground Check")]
public LayerMask groundMask;
public bool isGrounded;
isGrounded = Physics.CheckSphere(transform.position, 0.07f, groundMask);
void OnDrawGizmos()
{
// 체크하는 구체를 시각화
Gizmos.color = isGrounded ? Color.green : Color.red;
Gizmos.DrawWireSphere(transform.position, 0.07f);
}
유니티 스크립터블 오브젝트 (0) | 2025.01.15 |
---|---|
유니티 애니메이션 발(foot) 미끄러짐 해결하기 (0) | 2025.01.15 |
유니티 캐릭터 줌인 (Input Action) + 시네머신 가상 카메라 (0) | 2025.01.13 |
유니티 애니메이션 시간(몇초인지) 구하기 - animator.GetCurrentAnimatorStateInfo(index) (0) | 2025.01.12 |
믹사모(mixamo) unable to map your existing skeleton 에러 해결 (0) | 2025.01.09 |