unity/유니티 초보

Unity : 오브젝트 위치제어방법

rimugiri 2023. 1. 3. 23:41
728x90

유니티에서 좌표는 local, global로 구분되어 있다

 

local : object가 바라보고 있는 방향 기준

global : world좌표를 기준

 

유니티 object 제어 방법 : global

transform.position += new Vector3(0.0f, 0.0f, 0.1f) * Time.deltaTime * _speed;
//Vector3(0.0f, 0.0f, 0.1f) = Vector3.forward

유니티 object 제어 방법 : local

transform.Translate(Vector3.forward * Time.deltaTime * _speed);
transform.position += transform.TransformDirection(Vector3.forward * Time.deltaTime * _speed);
// Local -> World
// transform.TransformDirection

// World -> Local
// transform.InverseTransformDirection

*꿀팁 : X -> 유니티 안에서 local과 global 단축키를 변경할 수 있다

728x90