質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Unity3D

Unity3Dは、ゲームや対話式の3Dアプリケーション、トレーニングシュミレーション、そして医学的・建築学的な技術を可視化する、商業用の開発プラットフォームです。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Q&A

解決済

2回答

715閲覧

特定の条件下だと何故かスペースキーだけ反応しない

Lemon_0715

総合スコア60

C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Unity3D

Unity3Dは、ゲームや対話式の3Dアプリケーション、トレーニングシュミレーション、そして医学的・建築学的な技術を可視化する、商業用の開発プラットフォームです。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

0グッド

0クリップ

投稿2022/08/16 13:16

前提

if (Input.GetKeyDown(KeyCode.Space)) Jump();
という書き方でコードを書いていたのですが、

上下キーと左右キーのそれぞれどちらかを
同時に押している状態だとスペースキーが反応しませんでした。

スペースキーを他のキーに変更したら普通に実行されました。
スペースキーはGetKeyを複数使用している状態だと反応しないとか
そういう仕様があるのでしょうか?

ジャンプのメソッドのデバッグログが表示されないので、
ジャンプのメソッドそのものが呼ばれていないようです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Lemon_0715

2022/08/17 03:47

私のキーボードも上と右を入力している時だけはスペースキーが動作していたので恐らく同じ問題なのかなと思いました。 別のキーボードで試してみます。 ありがとうございます。
guest

回答2

0

One possible reason why the space key did not respond when other keys were pressed at the same time is that your keyboard has a limited key rollover. Key rollover is the ability of a keyboard to register multiple key presses simultaneously. Some keyboards have a low key rollover, which means they can only handle a few keys being pressed at once. If you press more keys than the keyboard can handle, some of them will be ignored or cause ghosting (false inputs).

To test your keyboard’s key rollover, you can use this online tool: https://joltfly.com/key-rollover-test/. It will show you how many keys your keyboard can register at the same time and which keys are affected by ghosting.

If your keyboard has a low key rollover, you can try to change the space key to another key that is less likely to conflict with other keys, such as Shift or Ctrl. Alternatively, you can use a keyboard that has a higher key rollover, such as a mechanical keyboard or a gaming keyboard.

Another possible reason why the space key did not respond is that there is a bug in your code or in Unity’s Input system. To debug your code, you can use Debug.Log statements to print out the values of Input.GetKeyDown for each key and see if they match your expectations. You can also use breakpoints and step through your code to see where it fails. To debug Unity’s Input system, you can use the Input Debugger window (Window > Analysis > Input Debugger) to inspect the state of all input devices and events.

投稿2023/05/24 11:42

AlishaJOstrom

総合スコア2

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

自己解決

Unity側ではなく自分のキーボードがそういう仕様だったみたいです
今度Amazonでゲーム用のキーボードでも買ってみます

投稿2022/08/18 13:26

Lemon_0715

総合スコア60

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問