Notice
Recent Posts
Recent Comments
Link
대왕휴지의 개발 공부
[Unity] 인스펙터에 있는 회전 값을 그대로 얻는 법 본문
https://forum.unity.com/threads/solved-how-to-get-rotation-value-that-is-in-the-inspector.460310/
[SOLVED] How to get "Rotation" value that is in the inspector?
Is there a direct way to get the value that are in the Rotation field of the inspector? I need that angle that is in the inspector. for example...
forum.unity.com
인스펙터에 있는 값을 그대로 얻기는 어렵다.
만약 인스펙터에 Local 좌표의 x에 음수값 -90도가 있다면
우리가 스크립트로 얻을 수 있는 x의 값은 270이다.
이 코드를 보자
이 코드의 WrapAngle함수는 음수값을 만들어주는 함수이다.
270에 -360을 해주니 -90이 잘 나온다.
인스펙터에 있는 음수값이 그대로 나온 것이다.!
암튼 인스펙터처럼 음수 값을 얻기 위해서 angle이 180이 넘어가면
360도를 빼주어서 음수값을 얻으면 된다!
'Unity' 카테고리의 다른 글
[Unity] .csv파일 데이터 파싱을 통한 대화 시스템 구현 2 : 데이터 파싱 관련 스크립트 설명 (0) | 2023.02.03 |
---|---|
[Unity] .csv파일 데이터 파싱을 통한 대화 시스템 구현 1 : CSV 규칙 설명 (1) | 2023.02.03 |
[Unity 2D] 대각선 각도 구하기 (0) | 2023.01.04 |
[Unity] rigidbody.MovePosition과 rigidbody.Position 그리고 transform.Position 차이 (부제: 쯔꾸르식 플레이어 이동) (0) | 2023.01.02 |
[Unity] Physics Material (0) | 2022.09.03 |