Keyboard and mouse input simulation for AI agents in Unity Play Mode.
- Unity 2021.3+
- com.lambda-labs.unity-repl 0.1.0+
- com.unity.inputsystem 1.0.0+ (for
InputAbility)
Add both packages to your project's Packages/manifest.json:
{
"dependencies": {
"com.lambda-labs.unity-repl": "https://github.com/LambdaLabsHQ/unity-repl.git",
"com.lambda-labs.unity-agent-input": "https://github.com/LambdaLabsHQ/unity-agent-input.git"
}
}// Must be in Play Mode
LambdaLabs.UnityAgentInput.InputAbility.PressKey(UnityEngine.InputSystem.Key.W);
// ... advance frames ...
LambdaLabs.UnityAgentInput.InputAbility.ReleaseKey(UnityEngine.InputSystem.Key.W);
LambdaLabs.UnityAgentInput.InputAbility.ClearAllInput();Unity's InputSystem processes the hardware event buffer each frame, which overwrites any
synthetic state injected mid-frame. InputAbility hooks InputSystem.onAfterUpdate to
re-inject held state after the buffer is fully processed, so synthetic inputs persist
correctly across frames.
This package is part of the Unity REPL project and is licensed under the GNU Affero General Public License v3.0.