中EN

Enhanced Input

  • Upgrade path from UE4 default input; radial dead zones, chorded actions, contextual input, prioritization, asset-based extensible processing. Enabled by default.
  • Mapping Contexts can be added/removed at runtime (CTRL: crouch while walking, slide while sprinting, stand while prone).
  • Four concepts: Input Actions, Input Mapping Contexts, Input Modifiers, Input Triggers.
  • Input Actions: data assets, the communication link with code; represent something the user can do. Value types: bool, Axis1D (float), Axis2D (FVector2D), Axis3D (FVector).
  • Trigger States/Events: Triggered, Started, Ongoing, Completed, Canceled. C++: UEnhancedInputComponent::BindAction(Action, ETriggerEvent::Triggered, this, &Func); FInputActionInstance::GetValue().Get().
  • Mapping Contexts: collection of actions for a context; Action → keys → triggers/modifiers; applied via Enhanced Input Local Player Subsystem with priority; highest priority context wins for same action... vehicle context added/removed on enter/exit; mutually-exclusive contexts avoid collisions. Example code: TSoftObjectPtr; AddMappingContext(InputMapping.LoadSynchronous(), Priority).
  • Modifiers: pre-processors altering raw values before triggers (axis order, dead zones, world space, sensitivity, smoothing). UInputModifier::ModifyRaw_Implementation; access UPlayerInput → Player Controller. Lyra aim inversion example. WASD: W Swizzle (YXZ/ZXY), A Negate, S Negate+Swizzle, D none.
  • Triggers: decide whether input activates action; minimum actuation, taps, holds, press/release; Chorded Action triggered with another action. By default any activity triggers every tick. Types Explicit / Implicit / Blocker; logic: no implicits/explicits → fires unless 0; explicits → at least one; implicits → all; blockers override → fail. States None/Ongoing/Triggered. Custom via UInputTrigger or UInputTriggerTimedBase (never returns Triggered itself); UInputTriggerHold (HoldTimeThreshold=1.0, bIsOneShot).
  • Player Mappable Input Config: preset collection of contexts (Default / Southpaw).
  • Debug: showdebug enhancedinput; showdebug devices. Inject: Input.+key Gamepad_Left2D X=0.7 Y=0.5; InjectInputForAction.
  • Platform Settings: UEnhancedInputPlatformData mapping context redirects per platform; in DefaultInput.ini, hot fixable.

引用这一章的笔记

输入关键词开始搜索

滚轮或双指缩放 · 拖动平移 · 双击放大 / 还原