スプライトを作成し、rigidbody 2d コンポーネントを適用しました。正常に動作しています。このコードを書きましたが、ゲームのプレイを開始すると、しばらく動作しますが、その後、重力が null のように見えます。これは、rigidbody を意味します。キーを離しても下がらない
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.LeftArrow)) {
posX--;
} else if (Input.GetKey (KeyCode.RightArrow)) {
posX++;
}
if (Input.GetKey (KeyCode.UpArrow)) {
posY++;
私がやりたいことは、ヘリコプターを上下左右に動かすことです(ユーザーが制御できます)が、ユーザーが操作していないときは、重力をデフォルトとして機能させ、ヘリコプターが重力のために下降するようにしたいのですが、どうすればそれを達成できますか?
} else if (Input.GetKey (KeyCode.DownArrow)) {
posY--;
}
angle -= Input.GetAxis ("Horizontal");
angle = Mathf.Clamp (angle, -10, 10);
}
void FixedUpdate()
{
transform.eulerAngles = new Vector3 (0,0,angle);
transform.position = new Vector2 (posX * Time.deltaTime, posY * Time.deltaTime);
}
}