0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Inputクラスについて(Unity)

Posted at

はじめに

Unityをまともに触り始めて一年くらいが経とうとしていますが、よくプレイヤーを動かすときに次のクラスを使います。

float horizontalInput = Input.GetAxis("Horizontal");
float VerticalInput = Input.GetAxis("Vertical");

ただ、実はこれがどういう仕組みで動いているのかをよくわからずに使っており「上矢印キー押したら前に進んだぞ」「Aキー押したら左に進んだぞ」って感じでした。さすがにその認識だとまずいよねって言うことでどういう仕組みで動いているのかをまとめます。

Inputクラス

これ、別に難しい仕組みでもなんでもなくて誰でも反応するキーとかを変更できるんですよね
タブから【Edit → Project Setting】をクリック、そのあと【InputManager → Axes → Horizontal(Vertical)】をクリックするとどのキーが反応するかを設定することができます。

ちなみにNegative Buttonがマイナス方向(Horizontalなら左、Verticalなら下)、Positive Buttonがプラス方向に行きます

スクリーンショット 2023-10-27 150520.png

おわりに

なんとなくで使うのではなくて、ちゃんと仕組みを理解しよう!!!(自分宛)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?