저번 글에서 움직임을 제어하기 위해 Rigidbody의 gravity와 kinematic에 접근하는 방법에 대해 알아봤다.
https://meongjeong.tistory.com/5
[UNITY] Rigidbody - useGravity, isKinematic 접근하기
GameObject의 물리 엔진을 동작하게 하는 Rigidbody!! 그 중에서 개인적으로 가장 자주 사용하는건 Use Gravity이다. (Is Kinematic은 그냥 같이..) 유니티 매뉴얼을 보면 Use Gravity 활성화되면 오브젝트는 중..
meongjeong.tistory.com
이번에는 Constraints에 접근하여 움직임에 제한을 줘보자.
<Constraints에서 Position과 Rotation 제한>
None | 모든 축에 대해서 회전과 움직임을 제한하지 않습니다. |
FreezePositionX | X축에 대해서 움직임을 제한합니다. |
FreezePositionY | Y축에 대해서 움직임을 제한합니다. |
FreezePositionZ | Z축에 대해서 움직임을 제한합니다. |
FreezeRotationX | X축에 대해서 회전을 제한합니다. |
FreezeRotationY | Y축에 대해서 회전을 제한합니다. |
FreezeRotationZ | Z축에 대해서 회전을 제한합니다. |
FreezePosition | 모든 축에 대해서 움직임을 제한합니다. |
FreezeRotation | 모든 축에 대해서 회전을 제한합니다. |
FreezeAll | 모든 축에 대해서 회전과 움직임을 제한합니다. |
<사용 방법>
Rigidbody Rigid;
void Start()
{
Rigid = GetComponent<Rigidbody>(); //Rigid 변수에 Rigidbody 컴포넌트 정보 전달
Rigid.constraints = RigidbodyConstraints.FreezePosition; //모든 축에 대한 움직임 제한
Rigid.constraints = RigidbodyConstraints.FreezeRotation; //모든 축에 대한 회전 제한
Rigid.constraints = RigidbodyConstraints.FreezAll; //모든 축에 대한 회전과 움직임 제한
}
출처 : 유니티 매뉴얼( https://docs.unity3d.com/kr/530/ScriptReference/RigidbodyConstraints.html )
Unity - 스크립팅 API: RigidbodyConstraints
Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. 닫기
docs.unity3d.com
'UNITY' 카테고리의 다른 글
[UNITY] Animation / Animator Controller 애니메이션 사용하기 (0) | 2022.04.04 |
---|---|
[UNITY] Find / FindWithTag | 오브젝트 찾기 (0) | 2022.01.10 |
[UNITY] Rigidbody - useGravity, isKinematic 접근하기 (0) | 2022.01.08 |
[UNITY] Application.Quit() 실행 중인 게임 종료하기 (0) | 2022.01.07 |
[UNITY] SetActive, ActiveSelf 오브젝트 활성화 / 비활성화에 접근하기 (0) | 2022.01.07 |