###前提・実現したいこと
下記コードでAキー、Dキーを押している間それぞれY軸の-方向、Y軸の+方向に回転するよう書きましたが、90度回転したら回転できないようにする機能をつけたいです。どのようにすればいいでしょうか?下記のコードに書き足す形で回答していただけると幸いです。わかりにくい質問文かと思いますがよろしくおねがいいたします。
###該当のソースコード
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class objectMoving : MonoBehaviour { 6 public float wSpeed = 10; 7 public float sSpeed = 7; 8 public float adRotate = 100; 9 10 // Use this for initialization 11 void Start () { 12 13 } 14 15 // Update is called once per frame 16 void Update () { 17 if (Input.GetKey (KeyCode.W)) { 18 this.transform.position += new Vector3 (0, 0, wSpeed) * Time.deltaTime; 19 } 20 if (Input.GetKey (KeyCode.S)) { 21 this.transform.position += new Vector3 (0, 0, -sSpeed) * Time.deltaTime; 22 } 23 if (Input.GetKey (KeyCode.D)) { 24 this.transform.Rotate(new Vector3 (0, adRotate, 0) * Time.deltaTime); 25 } 26 if (Input.GetKey (KeyCode.A)) { 27 this.transform.Rotate(new Vector3 (0, -adRotate, 0) * Time.deltaTime); 28 } 29 } 30} 31
「前提・実現したいこと」はコードではないので、コードタグ(```)で囲まないでください。

回答2件
あなたの回答
tips
プレビュー