タイトル: オブジェクトの移動・回転
移動
《Transform》.Tanslate( X値 , Y値 , Z値 );
回転
《Transform》.Rotate( X値 , Y値 , Z値 );
実装例
void Update() { if (Input.GetKey(KeyCode.UpArrow)) this.transform.Translate(0, 0.1f, 0); if (Input.GetKey(KeyCode.DownArrow)) this.transform.Translate(0, -0.1f, 0); if (Input.GetKey(KeyCode.RightArrow)) this.transform.Rotate(0, 0, -1f); if (Input.GetKey(KeyCode.LeftArrow)) this.transform.Rotate(0, 0, 1f); } |
簡略化するなら、こんな感じ
void Update() float h = Input.GetAxis("Horizontal"); this.transform.Rotate(new Vector3(v, 0, -h)); } |