void Update() { //ジャンプする if (Input.GetKeyDown(KeyCode.Space) && this.rigid2D.velocity.y == 0) { this.animator.SetTrigger("JumpTrigger"); this.rigid2D.AddForce(transform.up * this.jumpForce); } //左右移動 int key = 0; if (Input.GetKey(KeyCode.RightArrow)) { key = 1; } if (Input.GetKey(KeyCode.LeftArrow)) { key = -1; } //プレイヤの速度 float speedx = Mathf.Ads(this.rigid2D.velocity.x); //スピード制限 if (speedx < this.maxWalkSpeed) { this.rigid2D.AddForce(transform.right * key * this.walkForce); } //動く方向に応じて反転 if (key != 0) { transform.localScale new Vector3(key, 1, 1); } //プレイヤの速度に応じてアニメーション速度を変える if (this.rigid2D.velocity.y == 0) { this.animator.speed = 1.0f; } else { this.animator.speed = 1.0f; } //画面外に出た場合は最初から if (transform.position.y < -10) { SceneManager.LoadScene("GameScene"); } }