com.unity.ml-agents/Documentation~/InputSystem-Integration.md
The ML-Agents package integrates with the Input System Package through the InputActuatorComponent. This component sets up an action space for your Agent based on an InputActionAsset that is referenced by the IInputActionAssetProvider interface, or the PlayerInput component that may be living on your player controlled Agent. This means that if you have code outside of your agent that handles input, you will not need to implement the Heuristic function in agent as well. The InputActuatorComponent will handle this for you. You can now train and run inference on Agents with an action space defined by an InputActionAsset.
Take a look at how we have implemented the C# code in the example Input Integration scene (located under Project/Assets/ML-Agents/Examples/PushBlockWithInput/). Once you have some familiarity, then the next step would be to add the InputActuatorComponent to your player Agent. The example we have implemented uses C# Events to send information from the Input System.
com.unity.inputsystem version 1.1.0-preview.3 or later to your project via the Package Manager window.PlayerInput and Agent components attached.Additionally, see below for additional technical specifications on the C# code for the InputActuatorComponent.
IInputActionsAssetProvider InterfaceThe InputActuatorComponent searches for a Component that implements
IInputActionAssetProvider on the GameObject they both are attached to. It is important to note
that if multiple Components on your GameObject need to access an InputActionAsset to handle events, they will need to share the same instance of the InputActionAsset that is returned from the
IInputActionAssetProvider.
InputActuatorComponent ClassThe InputActuatorComponent is the bridge between ML-Agents and the Input System. It allows ML-Agents to:
ActionSpec for your Agent based on an InputActionAsset that comes from an IInputActionAssetProvider.This is accomplished by adding the InputActuatorComponent to an Agent which already has the PlayerInput component attached.
If using the InputActuatorComponent, install the com.unity.inputsystem package version 1.1.0-preview.3 or later.
For the InputActuatorComponent
InputControlsInputActuatorComponent