New Input System Part 1

Abhishek Smith

Abhishek Smith

Building Outscal | Land Jobs in the gaming industry | EA, Epic Games, TCS, | CMU, IIT K

NEW INPUT SYSTEM:

InputActionMap

  • Container for related input actions
  • Represents a gameplay context/state
  • One map active at a time (like Gameplay, UI, Menu)
  • Enable/Disable entire groups of inputs
  • Switch between maps during state changes
  • Example: "UIMap"- Menu navigation controls

InputAction

  • Single input definition (jump, move, shoot)
  • Can have multiple device bindings
  • Has specific value type (Button/Value/Vector2)
  • Processes input through interactions
  • Can modify input through processors

Setup

  • [SerializeField] InputActionAsset asset - Reference in Inspector
  • [SerializeField] PlayerInput playerInput - Add component
  • InputActionMap gameplayMap - Reference in script
  • InputAction moveAction - Individual action reference

Action Map Setup

  • Create: new InputActionMap("GameplayMap")
  • Enable: gameplayMap.Enable()
  • Disable: gameplayMap.Disable()
  • Get Action: gameplayMap.FindAction("move")

InputAction Properties

  • Name: Unique identifier
  • Type: Button/Value/Vector2
  • Control Scheme: Device grouping
  • Interactions: Tap/Hold/Press
  • Processors: Normalize/Invert/Scale

InputAction Phases

  • Started: Input begins
  • Performed: Input recognized
  • Canceled: Input ends

Binding Syntax

  • Single Key: "<Keyboard>/space"
  • Modifiers: "<Keyboard>/leftShift+w"
  • Mouse: "<Mouse>/position", "<Mouse>/scroll/y"
  • Gamepad: "<Gamepad>/buttonSouth", "<Gamepad>/rightTrigger"
  • Touch: "<Touchscreen>/touch*/position"
  • VR: "<XRController>{RightHand}/trigger"

Input Reading Methods

  • moveAction.ReadValue<Vector2>()
  • shootAction.ReadValue<float>()
  • jumpAction.IsPressed()
  • jumpAction.WasPressedThisFrame()
  • jumpAction.WasReleasedThisFrame()

Event System Methods

  • moveAction.performed += OnMove
  • moveAction.started += OnMoveStart
  • moveAction.canceled += OnMoveEnd
  • InputSystem.onDeviceChange += OnDeviceChange
  • playerInput.onActionTriggered += OnAction

Required Function Implementations

  • Awake(): Cache action references
  • OnEnable(): Subscribe to events
  • OnDisable(): Unsubscribe from events
  • OnMove(CallbackContext): Handle input
  • OnDestroy(): Cleanup

Runtime Checks Required

  • Null action references
  • Action enabled status
  • Valid bindings exist
  • Device connectivity
  • Control scheme validity

Show More