【3Dゲームエンジン】Unity総合スレッド26at GAMEDEV
【3Dゲームエンジン】Unity総合スレッド26 - 暇つぶし2ch607:名前は開発中のものです。
15/08/05 00:18:51.11 Wak/H5zk.net
Unity5.1.2でヘリコプターを使ったTPSを作っています。ヘリの操作で旋回や上昇、下降、前進は出来たのですが、
旋回時と前進時に旋回方向、進行方向にヘリを傾けたいと思っているのですが、上手くいきません。
var velocity = new Vector3 (0, 0, 0);
var rb = this.GetComponent<Rigidbody> ();
if (Input.GetAxis ("Vertical") != 0) {
velocity.y = Input.GetAxis("Vertical");
}
if(Input.GetAxis("Horizontal") != 0 &amp;&amp; !this.isGrounded){
transform.Rotate(new Vector3(0, rotateSpeed * Time.deltaTime * Input.GetAxis("Horizontal"), 0));
}
if(Input.GetButton("Fire2") &amp;&amp; !this.isGrounded){
rb.AddForce(transform.forward *speed,ForceMode.Force);
}
if (Input.GetButton ("Fire2") &amp;&amp; (Input.GetAxis ("Vertical") != 0 || Input.GetAxis ("Horizontal") != 0) &amp;&amp; !this.isGrounded) {
velocity.y = Input.GetAxis ("Vertical");
transform.Rotate (new Vector3 (0, rotateSpeed * Time.deltaTime * Input.GetAxis ("Horizontal"), 0));
rb.AddForce (transform.forward * speed, ForceMode.Force);
}
this.GetComponent<Rigidbody>().velocity = velocity * 500 * Time.deltaTime;
}
で操作しているのですが、Eulerで傾けようとするとRotateで打ち消されて傾いてくれません。
Y軸方向はGetAxisで、Z軸方向はGetKeyDownで対処しようとしたのですが、それでも上手くいきません。
どなたか旋回しながら、機体を傾ける方法をご存知の方教えてください。


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch