Real information about Unreal Engine 3

Sunday, March 31, 2013

Input Event Flow

If you ever tried to make a mod based on UTGame, you might have found in some situations you could not recieve user input in PlayerController. For example, when the pause menu pops up. This is because there are many layers of input handlers in UE. When an input handler receives an input event, the handler can capture it and prevent it from being processed by other handlers.

Input Handler


In UE, a class called Interaction represents the input handler. It has three delegate functions for scriptors to get input events:
  • OnReceivedNativeInputKey
  • OnReceivedNativeInputAxis
  • OnReceivedNativeInputChar
If these delegates return true, the input event will be considered as handled and will not be processed further.

Input Handler Chain


The following picture shows the input handlers and the class hiearchy in UE:
  • Console: This is the console which pops up when you press the Tilde key.
  • GFxInteraction: This is for the UI based on Scaleform GFx.
  • UIInteraction: This is for the old UI system.
  • PlayerManagerInteraction: This passes input events to PlayerInputs within PlayerControllers.
  • Input: This supports the key binding feature in UE.
  • PlayerInput: Object within PlayerController which is responsible for tracking player input.

The main input handler chain is stored in an array named GlobalInteractions within GameViewportClient. Console, GFxInteraction, UIInteraction, and PlayerManagerInteraction are inserted to the handler chain in the Init function. You can add your own input handler by calling InsertInteraction(). Besides, you can also use the input delegates in GameViewportClient, which are called before GlobalInteractions.

Moreover, there is another input handler chain stored in the Interactions array within PlayerController. In PlayerController's InitInputSystem(), it will insert a PlayerInput into its Interactions. The forementioned PlayerManagerInteraction will pass recieved input events to the Interactions in PlayerController. That's how PlayerInput gets input. So next time when you have troubles with input events, you might check the handler chain first to see what's going wrong.

0 comments :

Post a Comment

Followers

AD (728x90)

Powered by Blogger.