unity-input-system
できること
最新のInput Systemパッケージを使い、Unityでプレイヤーの入力を読む方法を説明します。キーボード、ゲームパッド、タッチスクリーンのどれでも動く操作がほしい開発者向けです。
使う場面
- ✓Unityのゲームに、移動、ジャンプ、射撃の操作を加えているとき。
- ✓プロジェクトに、入力アクションのファイルがあるか、Input Systemパッケージが入っているとき。
- ✓プレイヤーがキーの割り当てを変えたり、ゲームパッドとキーボードを切り替えたりできるようにしたいとき。
スキルのリンク
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/unity/unity-input-system/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“WASD、左スティック、タッチのジョイスティックで私のキャラクターが動くように、Unityの操作を設定してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
スキルは、エージェントがプロジェクトの入力の扱いを設定し、入力アクションをファイルで定義し、それをキャラクターに接続し、イベントを使うか、フレームごとに確かめるかのどちらかで値を読むよう導きます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Unity Input System (new)
Read input through Unity's Input System package (com.unity.inputsystem 1.x; Unity 6.3 LTS
ships 1.20) — action-based, device-agnostic, rebindable. Targets Unity 6.3 LTS. This is the modern
replacement for the legacy Input.GetAxis/Input.GetKey Input Manager.
When to use
- Use when setting up movement/jump/fire input, defining an
.inputactionsasset with action maps and control schemes, wiring aPlayerInputcomponent, reading aVector2stick/WASD value, or handling gamepad + keyboard + touch from one set of actions. - Use when
Packages/manifest.jsoncontainscom.unity.inputsystemor the project has an*.inputactionsasset.
When not to use: rebindable-control architecture across engines → input-systems
(this skill is the Unity-specific API). Moving the character once you have the input vector
→ unity-physics / unity-csharp-scripting.
Core workflow
- Check Active Input Handling (Project Settings → Player). The package only receives
input when this is
Input System Package (New)orBoth.Bothis required if any oldInput.GetAxiscode remains. - Find or create the
.inputactionsasset. New Unity 6 projects usually already have one assigned as the project-wide actions (Project Settings → Input System Package; the template file isInputSystem_Actions.inputactions) — reuse it rather than adding a second asset. Add an action map (e.g.Gameplay), add actions (Move= Value/Vector2,Jump= Button,Fire= Button), and bind them to controls and composite bindings (WASD = 2D Vector composite). - Choose how to read it:
PlayerInputcomponent (designer-friendly) — drop it on the player, point it at the asset, pick a Behavior (Send Messages / Broadcast / Invoke Unity Events / Invoke C# Events). Best for single/local-coop players.- Project-wide actions in code (
InputSystem.actions.FindAction("Move")) — no asset reference to wire up, and the actions are already enabled. - Direct in code (
InputActionReference/InputActionAsset) — most control; youEnable()actions and read them. Best for systems and tools.
- Enable the actions/maps you read.
PlayerInputenables its default map automatically and project-wide actions start enabled; actions from any other asset must be.Enable()d (and disabled on teardown). - Switch action maps for context (gameplay ↔ UI/menu) instead of guarding every handler.
- Verify with the Input Debugger (Window → Analysis → Input Debugger) to confirm devices and that actions fire.
Patterns
1. PlayerInput with "Send Messages" (handlers on the same GameObject)
using UnityEngine;
using UnityEngine.InputSystem;
// PlayerInput (Behavior = Send Messages) calls On<ActionName>(InputValue) by name.
public class PlayerInputReceiver : MonoBehaviour
{
private Vector2 _move;
private void OnMove(InputValue value) => _move = value.Get<Vector2>(); // Move action
private void OnJump(InputValue value) { if (value.isPressed) Jump(); } // Button action
private void Update() { /* drive movement from _move */ }
private void Jump() { }
}
2. Reading an action directly in code (polling a value)
using UnityEngine;
using UnityEngine.InputSystem;
public class DirectMover : MonoBehaviour
{
[SerializeField] private InputActionReference moveAction; // assign the Move action
private void OnEnable() => moveAction.action.Enable(); // REQUIRED or it reads zero
private void OnDisable() => moveAction.action.Disable();
private void Update()
{
Vector2 move = moveAction.action.ReadValue<Vector2>(); // continuous value
transform.Translate(new Vector3(move.x, 0, move.y) * (5f * Time.deltaTime));
}
}
3. Project-wide actions (no asset reference)
using UnityEngine;
using UnityEngine.InputSystem;
public class ProjectWideMover : MonoBehaviour
{
private InputAction _move, _jump;
private void Awake()
{
// Looked up once; project-wide actions are preloaded and enabled by default.
_move = InputSystem.actions.FindAction("Move");
_jump = InputSystem.actions.FindAction("Jump");
}
private void Update()
{
Vector2 move = _move.ReadValue<Vector2>();
if (_jump.WasPressedThisFrame()) { /* jump */ }
}
}
4. Event callbacks + switching acti
よくある質問
入力アクションとは何ですか?
Jumpのような名前付きの操作で、多くのキーやボタンから発動できるものです。
古い入力の呼び出しが動かないことがあるのはなぜですか?
スキルは、パッケージが入力を受け取るには、プロジェクトの入力の設定で新しいInput Systemを含める必要があると注意しています。
キャラクターの移動も扱いますか?
完全には扱いません。移動の物理は、別のUnityのスキルで扱われます。
詳細
作者による元の説明
Wire player input in Unity 6.3 LTS with the Input System package: Input Actions, action maps, the PlayerInput component, and reading values via callbacks or polling. Use when the project has a .inputactions asset or com.unity.inputsystem, or when the user mentions the Unity Input System, InputAction, action maps, PlayerInput, control schemes, or rebinding.
人気
- GitHubのスター
- 6.6k
- ランキング
- #13847
- ライセンス
- Apache-2.0
- 更新日
- 2026/10/28
コメント
- …
このリポジトリの他のスキル
router
6.6kエージェントが、エンジンとタスクの種類を見分けて、依頼に合ったゲーム開発のスキルを選べるよう支援します。
ai-behavior-trees-utility-ai
6.6kエージェントが、優先度と点数によって行動を選ぶ、ゲームの敵やキャラクター向けのビヘイビアツリーとユーティリティAIのシステムを作れるよう支援します。
audio-design
6.6kエージェントが、オーディオバス、デシベルでの音量、会話中の音の抑え込み(ダッキング)、適応型の音楽、効果音のバリエーションなど、ゲームのサウンドのミキシングを教えます。
camera-systems
6.6kエージェントが、なめらかに追従し、レベルの内側に収まり、3Dで周回したり見回したりできるゲームのカメラを作れるよう支援します。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。