Mostly Harmless

UE2:Interaction (UT2004)

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 12:26, 5 January 2012 by Krylose (Talk | contribs) (ScreenToWorld)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
UT2004 Object >> Interactions >> Interaction
Package: 
Engine
Direct subclasses:
BaseGUIController, Console, StreamInteraction, UtvInteraction
Known custom subclass:
Crusha/UltimateMappingTools/UltimateRadarMap
This class in other games:
UE2Runtime, UT2003, UDK, UT3

Generally an Interaction can be used to capture player input and render to the Canvas. If you only want to render additional info to the Hud, try using a HudOverlay instead. Interactions are the only non-Actor objects that can use states, but they don't support state code outside functions.

Interactions can be registered in two ways, either as a global interaction or as a local interaction. Global interactions are stored in a dynamic array of the InteractionMaster while each Viewport (native-only subclass of Player) contains an array of local interactions. Whether an interaction is created as local or global interaction is just a matter of passing a Viewport reference to InteractionMaster.AddInteraction() or not.

Properties[edit]

bActive[edit]

Type: bool

Whether this Interaction currently wants to receive KeyType() and KeyEvent() calls.

Default value: True

bNativeEvents[edit]

Type: bool

Whether this interaction wants to receive events natively instead of getting its UnrealScript functions called.

bRequiresTick[edit]

Type: bool

Whether this Interaction currently wants to receive Tick() calls.

bVisible[edit]

Type: bool

Whether this Interaction currently wants to receive PreRender() and PostRender() calls.

Master[edit]

Type: InteractionMaster

Reference to the InteractionMaster.

ViewportOwner[edit]

Type: Player

References the owning Viewport for local interactions. None for global interactions.

Functions[edit]

Native functions[edit]

ConsoleCommand[edit]

native function bool ConsoleCommand (coerce string S)

Executes a console command in the context of the local player. This is the function that processes all commands you enter at the in-game console. This function returns False if the console command doesn't exist. Output of commands executed through this function can be captured with the Message() event by all registered global and local interactions.

Initialize[edit]

native function Initialize ()

Initializes the interaction's state support, then calls the Initialized() event. This is called automatically by InteractionMaster.AddInteraction(), so you don't need to call it again.

ScreenToWorld[edit]

native function Object.Vector ScreenToWorld (Object.Vector Location, optional Object.Vector CameraLocation, optional Object.Rotator CameraRotation)

Converts local screen coordinates (Location) to a directional vector in global world coordinates. The CameraLocation and CameraRotation default to 0 if omitted, giving a position relative to the eye of the camera.

WorldToScreen[edit]

native function Object.Vector WorldToScreen (Object.Vector Location, optional Object.Vector CameraLocation, optional Object.Rotator CameraRotation)

Converts global world coordinates (Location) to local screen coordinates. The CameraLocation and CameraRotation default to the local PlayerController's position if omitted.

Events[edit]

Initialized[edit]

event Initialized ()

Called by the Initialize() function after state support has been initialized, so this is the first place where you can use GotoState() to switch to a specific state.

NotifyLevelChange

event NotifyLevelChange ()

Called by the engine right before the current level changes. This is the best place to unregister game-specific interactions by calling Master.RemoveInteraction(Self). Failing to unregister an interaction may cause problems in network games, including kicks and bans by anti-cheat mods!

Global interactions receive this event before local interactions.

NotifyMusicChange

event NotifyMusicChange ()

Doesn't seem to get called, probably a left-over from UT2003 and now replaced by StreamFinished().

Other instance functions[edit]

KeyEvent[edit]

function bool KeyEvent (out Interactions.EInputKey Key, out Interactions.EInputAction Action, float Delta)

Called for active (bActive) interactions for every key, button and axis input event from keyboards, mice, joysticks, gamepads and similar devices. Returning True from this function will "swallow" the event. Later interactions and the game's own input handling will not receive the key event in this case.

Global interactions receive this event before local interactions.

KeyType[edit]

function bool KeyType (out Interactions.EInputKey Key, optional string Unicode)

Called for active (bActive) interactions for every key press - think typing in a text editor. When you press and hold a key, this function is called repeatedly according to the operating system's keyboard setting. Key is the key that was pressed, Unicode is the actual Unicode text associated with the key. Returning True from this function will "swallow" the event. Later interactions will not receive the key event in this case.

Global interactions receive this event before local interactions.

Message[edit]

function Message (coerce string Msg, float MsgLife)

Called for all interactions from within ConsoleCommand for output of the executed command.

Global interactions receive this event before local interactions.

PostRender[edit]

function PostRender (Canvas Canvas)

Called for visible (bVisible) interactions after Hud.PostRender() has finished.

Global interactions receive this event after local interactions.

PreRender[edit]

function PreRender (Canvas Canvas)

Called for visible (bVisible) interactions before the world is rendered. Drawing onto the canvas works already.

Global interactions receive this event before local interactions.

SetFocus[edit]

function SetFocus ()

Moves the interaction to the start of the (global or local) interactions list and makes it active and visible.

StreamFinished[edit]

function StreamFinished (int Handle, Interactions.EStreamFinishReason Reason)

Called only for local interactions when a custom music stream (not the level music) has finished. This is a stub for the StreamInteraction class.

Tick[edit]

function Tick (float DeltaTime)

Called for interactions that want to be ticked (bRequiresTick) after all actors have been ticked. Unlike Actor.Tick(), the interaction event is called regardless whether the game is paused or in PlayersOnly mode.

Global interactions receive this event before local interactions.