반응형
유니티 회전
잊을만하면 각도변경을 해야하는 경우가 있다.
매번 구글링 해서 찾게 되는대..
transform rotation
private void Start()
{
GameObject test = new GameObject();
test.transform.rotation = Quaternion.Euler(new Vector3(x, y, z));
}
rotation은 오브젝트 절대적인 각도를 지정하는 것이다.
test의 각도를 new Vector3(x, y, z)로 고정시킬 때 사용한다.
transform Rotate
private void Update()
{
GameObject test = new GameObject();
test.transform.Rotate(new Vector3(x, y, z) * Time.deltaTime);
}
Rotate는 오브젝트 각도의 변경을 지속적으로 실행할 때 사용한다.
즉, 회전시킬 때 사용하는 것으로
test의 각도를 new Vector3(x,y,z) 방향으로 매 프레임마다 이동시킨다.
transform RotateAround
private void Update()
{
GameObject test = new GameObject();
GameObject target = new GameObject();
test.transform.RotateAround(target.transform.position, Vector3.up, 10 * Time.deltaTime);
}
RotateAround는 target 포지션을 기준으로 회전한다.
target의 위치, 회전방향, 회전속도를 지정한다.
Rotate와 RotateAround는 기준이 target인지 오브젝트 자신인지의 차이점을 가진다.
반응형
'개발 공식 > Unity' 카테고리의 다른 글
Unity URP Overlay Camera 한 화면에 두 개의 카메라 (1) | 2022.11.29 |
---|---|
유니티 unity monobehaviour 상속 override start 이벤트 (1) | 2022.11.25 |
[Unity/UI] 텍스트 배경크기조절하는법("Parent has a type of layout group" error) (0) | 2022.01.27 |
댓글