-
방식1
void Update() { if(Input.GetKey(KeyCode.UpArrow)) { this.transform.Translate(Vector3.forward * Time.deltaTime); } }
if(Input.GetKeyDown(KeyCode.Delete)) { this.transform.position = Vector3.zero; }
방식2
float mH, mV; //... mH = Input.GetAxis("Horizontal"); mV = Input.GetAxis("Vertical"); this.transform.Translate(Vector3.up * Time.deltaTime * mH); this.transform.Translate(Vector3.right * Time.deltaTime * mV);
만약 Input.GetAxis에 "Horizontal", "Vertical"값이 안되는 경우, Edit -> Project setting -> Input에서 명칭이나 기타 값들이 정상인지 확인해봐야 한다
기타
'Unity' 카테고리의 다른 글
Unity - Texture Sprite (2d animation) (0) 2020.11.10 Unity - UnityChan 간단 사용(내장Script) (0) 2020.11.08 Unity - UnityChan 사용준비 (0) 2020.11.08 Unity - UnityChan License (0) 2020.11.08 Unity - Transform 얻기 (0) 2020.11.08 Unity - GameObject 얻기 (0) 2020.11.08 Unity - Culling Mask (0) 2020.11.07 Unity Component - Camera (0) 2020.11.07