Home › Systems › AFS_Core_Pawn
System

AFS_Core_Pawn

The VR, desktop and mobile pawns, touch input, and the C++ hand-tracking and gesture system with its Hand Pose Studio editor.

What it gives you

  • Three pawn families in Pawn and Character variants
  • Hand tracking, gesture recognition and synthetic input keys
  • Hand Pose Studio for authoring grip poses

Requires

AFL_Libraries AFM_Abilities AFM_Replication AFM_Settings AFM_State AFM_Teleport AFS_Core_MotionController

Engine: OpenXR OpenXRHandTracking

Required by

AFS_Core_MotionController AFS_UI_Menu AF_Examples

10 assets40 API members

Description

This module provides the player. Three pawn families — VR, desktop and mobile — each in a plain Pawn and a Character variant, so you can choose between simple movement and full character movement without changing anything else.

The VR pawn spawns its motion controllers as actors rather than components, attached to a CameraHandle that sits between the actor root and the camera. That separation is what makes room-scale work: the capsule can be recentred under the player's head and its height adjusted to the real player without dragging the tracked camera with it. The motion controller actors themselves, their hands and the gesture definitions are in AFS_Core_MotionController.

Hand tracking is handled in C++. Gestures are described declaratively as data assets — finger curl ranges, bone distances, bone angles, a hold time and a priority — and when one is recognised the module injects a synthetic input key. That means gestures bind in Enhanced Input exactly like a controller button, and no ability needs to know gestures exist.

Setup

  1. For VR, run the PC VR or Quest setup in the Setup window (Tools > Advanced Framework Pro > Setup). OpenXR and OpenXR Hand Tracking are enabled with the plugin.
  2. Subclass the pawn you need — start from BP_Pawn_VR_Char_Showroom in AF_Examples rather than the raw BP_Pawn_VR_Char, since the showroom variant already has the common abilities attached.
  3. On the VR pawn, set Left Controller and Right Controller to the motion controller classes you want. AFS_Core_MotionController ships controller and hand variants of each.
  4. Assign your pawn classes in the level's PDA_Level.
Assigning motion controller classes on the VR pawn
AFS_Core_Pawn_setup.pngAssigning motion controller classes on the VR pawn
Assigning motion controller classes on the VR pawn
Tip

With no headset connected the VR pawn still spawns its controllers, pinned to fixed offsets in front of the camera. This keeps VR code paths exercised when you test in a flat editor window.

Usage

Choosing which pawn spawns

You do not choose in the level — you choose in the PDA_Level data asset. Leave Pawn Select on Dynamic and the framework detects headset, then mobile platform, then falls back to desktop.

Adding an ability to a hand

Add a BPC_ControllerAbility subclass to the motion controller Blueprint, not to the pawn. It receives its pawn, controller and side through InitiateControllerAbility.

Recentring the capsule after movement

Call Interface_RecenterCapsule on the pawn. Locomotion already does this; call it yourself if you move the player by other means.

Defining a gesture

Create a UAFSHandGestureDefinition data asset. Add finger curl rules, bone distance rules and bone angle rules — all must pass simultaneously. Set Min Hold Time to avoid flicker and Priority to resolve overlaps. Assign the left and right input keys, then bind those keys in your input mapping context.

A gesture definition with curl and distance rules
AFS_Core_Pawn_gesture_dataasset.pngA gesture definition with curl and distance rules
A gesture definition with curl and distance rules

Authoring a hand pose

Use Hand Pose Studio — see Author a hand pose.

Key properties

PropertyOnWhen to change
Left Controller / Right ControllerBP_Pawn_VRTo swap between controller meshes and hand meshes, or to your own
Trace DistanceBPC_Input_TouchTo change how far mobile touch input reaches
Min Hold TimeGesture definitionRaise if a gesture flickers on and off
PriorityGesture definitionRaise when two gestures can both match the same hand shape

Extending

Derive from a pawn, implement BPI_PawnInfo, and return the right E_Pawn_Type. Assign it in PDA_Level and the rest of the framework adapts.

To add a new gesture, create a data asset — no code. To add a new synthetic key, extend FAFSGestureInputKeys in C++ and register it during module startup.

Performance notes

Performance

The VR pawn's AutoAdjustCapsuleHeight polls on a 0.5 s loop rather than ticking. Gesture evaluation runs per hand per frame while hand tracking is active — if you define many gestures, use Priority and Min Hold Time to keep the matching set small.

Example map

Map_Examples_VRHands demonstrates hand tracking, custom poses and gesture-driven interaction.

Troubleshooting

The player spawns at floor height. The pawn is the plain Pawn variant where the Character variant was expected, or teleport location correction is not being applied.

Hands do not appear. The motion controller classes are not assigned on the pawn, or OpenXR Hand Tracking is not enabled.

A gesture never fires. Its rules cannot all be satisfied simultaneously — widen a curl range first, since those are the most commonly over-tightened.

API reference

Every blueprint asset in this module. Expand an asset to see its members.

Blueprints/Desktops

BP_Pawn_Desktop3 members
extends Character · implements BPI_Trace, BPI_PawnInfo, BPI_AbilityRestriction

Base keyboard-and-mouse pawn: a character with a camera, the pawn interaction state component and the character teleport ability. Handles look, move, jump, crouch and sprint from the desktop mapping context, switches between Game Only, Game and UI and UI Only control modes, and answers the trace contract by tracing from the camera or the mouse and caching the hit for a fiftieth of a second. Subclass it to add abilities; the Char variant adds a visible body.

KindNameSignatureDescription
fnResetTraceTimer()Internal handler that marks the cached trace stale so the next Get Latest Trace runs a fresh line trace. Fired by a timer set to the trace refresh interval rather than called directly.
eventClient_Possessed(NewController: Controller)Called on the owning client once the pawn has a controller. Waits until the pawn really is locally controlled, adds the desktop input mappings, applies the current screen control mode, puts the crosshair on screen and hands the pawn to every pawn ability.
eventClient_Unpossessed(OldController: Controller)Called on the owning client when the pawn loses its controller. Removes the desktop input mappings, unpossesses every pawn ability and takes the crosshair off screen.
BP_Pawn_Desktop_Char0 members
extends BP_Pawn_Desktop

Desktop pawn with a visible body: head, torso and headset meshes marked owner-no-see, so other players in a networked session see a figure where the local player sees only the view from the camera. It adds no behaviour beyond the desktop pawn it inherits from, so subclass it, as the showroom pawns do, to give the pawn the abilities it needs.

No editor-visible members; this asset configures defaults only.

Blueprints/Mobile

BP_Pawn_Mobile2 members
extends Character · implements BPI_AbilityRestriction, BPI_Trace, BPI_PawnInfo

Base touch pawn: a character with a camera, the touch input component, the pawn interaction state component and the character teleport ability. One finger swiping turns and pitches the view, a double tap on ground within thirty degrees of level teleports the pawn there, and focus and traces follow the first finger through the trace contract. Subclass it to add abilities; the Char variant adds a visible body.

KindNameSignatureDescription
eventClient_Possessed(NewController: Controller)Called on the owning client once the pawn has a controller. Waits until the pawn really is locally controlled, adds the mobile input mappings and hands the pawn to every pawn ability.
eventClient_Unpossessed(OldController: Controller)Called on the owning client when the pawn loses its controller. Removes the mobile input mappings and unpossesses every pawn ability.
BP_Pawn_Mobile_Char0 members
extends BP_Pawn_Mobile

Touch pawn with a visible body: head, torso and headset meshes marked owner-no-see, so other players in a networked session see a figure where the local player sees only the view from the camera. It adds no behaviour beyond the mobile pawn it inherits from, so subclass it, as the showroom pawns do, to give the pawn the abilities it needs.

No editor-visible members; this asset configures defaults only.

Blueprints/VR

BP_Pawn_VR9 members
extends Character · implements BPI_Pawn_VR, BPI_PawnInfo, BPI_AbilityRestriction, BPI_Trace

Base VR pawn: a character carrying the camera on a replicated camera handle, alongside the character teleport ability. It spawns one motion controller per hand from the Left Controller and Right Controller class settings, recentres the capsule under the head, matches capsule height to the camera, and applies ability restrictions to its own pawn abilities and to every controller ability on either hand. Choose the controller classes, then subclass it to add abilities.

KindNameSignatureDescription
fnResetTraceTrace()Clears the pawn's valid-trace flag, so anything reading the trace treats it as nothing being under the pointer until the next trace fills it in again.
fngetFocussedComponentDebug(out SceneComponent: SceneComponent)Debug stub with no implementation behind it. Always returns nothing, whatever the move focus setting.
fnCorrectPawnPositionPawn(InVector: Vector, InRotation: Rotator, UseRotation: bool, out Location: Vector, out Rotation: Rotator)Returns the actor location and rotation needed to put the headset, rather than the capsule, at the position you ask for. Only the horizontal offset between capsule and camera is removed, so height is left alone; with Use Rotation on, the supplied rotation is corrected by the player's current head yaw as well.
fnSetupMotionControllerControls(MotionControllerClass: class<BP_MotionController>, Side: E_Side)Replaces the hand on one side: destroys the controller already registered there, then spawns the given class attached to the camera handle with the pawn and side already filled in. Passing no class leaves that side empty.
eventSwitchControllers(LeftController: class<BP_MotionController>, RightController: class<BP_MotionController>)Swaps both hands at once, destroying whatever is there and spawning the two given classes for left and right. Use it to move between hand meshes and controller meshes at runtime.
eventServer_PrepareVRPawn()Spawns the left and right controllers configured on the pawn. Runs on the server; called from Client Possessed once the pawn is locally controlled.
eventAutoAdjustCapsuleHeight(Set: bool)Starts a twice-a-second loop that resizes the capsule to match the player's head height, clamped between 40 and 300 centimetres, and shifts the actor and camera handle by the same amount so the view does not jump. Only corrects drifts of 15 centimetres or more; pass false to end the loop.
eventClient_Possessed(NewController: Controller)Called on the owning client once the pawn has a controller. Waits until the pawn really is locally controlled, prepares the VR pawn and spawns the hands, forces Game Only input with the cursor hidden, sets the spectator screen to a single cropped eye and hands the pawn to every pawn ability.
eventClient_Unpossessed(OldController: Controller)Called on the owning client when the pawn loses its controller, and unpossesses every pawn ability. The spawned hands are left alone; destroy them yourself if the pawn is to be reused.
BP_Pawn_VR_Char0 members
extends BP_Pawn_VR

VR pawn with a visible body: head and torso meshes marked owner-no-see, so other players see an avatar while the wearer sees only the world, with the camera raised to standing height. It adds no behaviour beyond the VR pawn it inherits from, so subclass it, as the showroom pawns do, to give the pawn the abilities it needs.

No editor-visible members; this asset configures defaults only.

Components

BPC_Input_Touch22 members
extends ActorComponent

Actor component turning raw touch into gestures. Feed it Touch Pressed, Moved and Released and it keeps each finger's location, starting location, delta, smoothed swipe delta and duration, then broadcasts a delegate for single and double taps with one or two fingers, for swipes and for drags, and presses named keys so the same gestures can be bound as Enhanced Input actions. It also keeps a line trace under the first finger unless Use Trace is off. Add it to a pawn that takes touch input.

KindNameSignatureDescription
varMax Tap TimeSettingsfloatmaximum time in seconds that allows a touch to be registered as tap
varMax Double Tab TimeSettingsfloatmaximum time in seconds that can be between to taps if they are to be registered as double tap
varSwipe Sensitivity ThresholdSettingsfloatthe minimum amount of pixels the finger has to move for a swipe to be recognized.
varSwipe Interpolation SpeedSettingsfloatSmoothing speed applied to the swipe delta before it is broadcast through On Swipe Update Interpolated, which is what the mobile pawn steers its camera with. Higher values track the finger more closely and jitter more.
varHold TimeSettingsfloattime in seconds until hold is registered
varUse TraceTraceboolWhether a world trace is run under the first finger on press and on tap. Switch it off to save the trace, but Get Latest Trace then never refreshes and anything that reads it, such as double-tap teleport, stops responding.
varTrace Hit DistanceTracefloatHow far into the world the touch trace reaches from the camera, in centimetres. Surfaces beyond it are never reported as a hit.
fnClearIndex(Index: ETouchIndex)Forgets a finger entirely, removing its location, initial location, delta, duration and classification. Called on release, and also on the partner finger of a two-finger tap so it cannot fire a second time.
fnisAnyOtherFingerTabbing(IgnoreIndex: ETouchIndex, out Found: bool, out FoundIndex: ETouchIndex)Returns the first finger other than the one you pass in that is still classified as a tap. Used on release to tell a two-finger tap from a one-finger tap; Found is false when no other finger is down.
fngetTouchFunctionGetter(Index: ETouchIndex, out Function: E_Touch_Function)Returns what a finger is currently being treated as, tap, swipe or drag. Every touch starts as a tap and is reclassified as it moves; an untracked index reports None.
fngetTouchDurationGetter(Index: ETouchIndex, out Duration: float)Returns how long a finger has been held down, in seconds, counted from the moment it was pressed. Comes back as zero for a finger that is not being tracked.
fngetTouchDeltaGetter(Index: ETouchIndex, out Delta: Vector2D)Returns how far a finger has moved since the last update, in screen pixels. Left at zero for a finger that is not being tracked.
fngetTouchInitialLocationGetter(Index: ETouchIndex, out Location: Vector2D)Returns the screen position at which a finger first went down, which is the anchor a swipe or drag is measured from. Comes back as zero once that finger has been released.
fngetTouchLocationsGetter(Index: ETouchIndex, out Found: bool, out Location: Vector2D)Returns the latest screen position of a finger, with Found telling you whether that finger is being tracked at all. Location is meaningless when Found is false.
fngetAngleAndDegreeUtil(InitialVector: Vector2D, EndVector: Vector2D, IntervalSize: int, out Angle: float, out Index: int)Returns the direction from one screen point to another as an angle in degrees, wrapped to 0-360. The interval index is meant to bucket that angle into equal segments, but the division is inverted, so it comes back as zero for any interval size below a full turn.
fnTouchReleasedTouch(Index: ETouchIndex, TouchLocation: Vector)Ends tracking of a finger: raises Event Touch Released with the duration it was held, which is where taps, swipes and drags are dispatched, and then clears every map entry for that index.
fnTouchMovedTouch(Index: ETouchIndex, TouchLocation: Vector)Updates the stored screen position for a finger and raises Event Touch Moved. The delta and the tap or swipe classification are worked out on tick, not here.
fnTouchPressedTouch(Index: ETouchIndex, TouchLocation: Vector)Starts tracking a finger: records its location as both the current and the initial position, zeroes its duration and delta, classifies it as a tap for now, and raises Event Touch Pressed. Call it from the pawn's touch input binding.
eventEventTouchPressed(TouchIndex: ETouchIndex, ScreenLocation: Vector2D)Raised by Touch Pressed once the finger has been recorded, and refreshes the world trace under it. Bind to it to react to a finger going down before it has been classified.
eventEventTouchReleased(TouchIndex: ETouchIndex, ScreenLocation: Vector2D, Duration: float)Raised by Touch Released and does the actual gesture dispatch. A tap becomes a one- or two-finger single or double tap, broadcasts the matching delegate and pulses a synthetic input key for a twentieth of a second; a swipe broadcasts On Swipe End; a drag broadcasts On Drag Release.
eventEventTouchMoved(TouchIndex: ETouchIndex, ScreenLocation: Vector2D)Raised by Touch Moved after the finger's stored position has been updated. Empty by default; bind to it to react to finger movement without polling.
eventUpdateTrace(Index: ETouchIndex, ScreenPosition: Vector2D)Line traces from the given screen position into the world on the visibility channel and stores the result as the latest trace, which the mobile pawn hands out through Get Latest Trace. Only the first finger traces, and only while Use Trace is on.

Interfaces

BPI_Pawn_VR1 members
extends Interface

Contract letting a motion controller announce itself to the VR pawn it belongs to, along with the hand side it stands for. The pawn records it in its per-side controller map and, when no headset is running, parks it in front of the camera so the setup still works on a flat screen. Implement it on a VR pawn of your own that has to accept the framework's controllers.

KindNameSignatureDescription
fnInterface_RegisterControllerToVRPawnVR Pawn(MotionController: BP_MotionController, Side: E_Side)Implemented by the VR pawn to take ownership of a freshly spawned motion controller for one hand. The controller calls it on itself so the pawn can look it up later by side, for example when applying an ability restriction to both hands.

Settings

BP_Value_Settings_Float_Pawn_Speed1 members
extends BP_Value_Settings_Float

Ready-made slider for how fast the pawn moves, scaling the movement ability's speed. Point a slider row at it to put locomotion speed on a settings screen.

KindNameSignatureDescription
eventValue_setFloatValue_Float(SourceInfo: ST_SourceInfo, Value: float)Implemented by a float value to take a new value from the pawn described by the source info. Sliders call it as their handle moves; the drag state reads the value as 0 to 1 across its own range.

Widgets/Crosshair

Widget_Crosshair2 members
extends UserWidget

Screen-centre crosshair for the desktop pawn, which creates it on possession and adds it to the viewport. Its colour comes from the pawn's interaction state component, so it follows whatever is under the pointer, and it hides itself whenever the mouse cursor is showing or the control mode is anything other than Game Only. The desktop pawn names this class directly, so change the look by editing it rather than by pointing the pawn elsewhere.

KindNameSignatureDescription
fnGet_Crosshair_ColorAndOpacity_0() → LinearColorReturns the tint for the crosshair image, taken from the interaction state the pawn is currently in, which is how the crosshair changes as you look at something you can act on. Falls back to opaque white when the pawn has no interaction state component.
fnShouldCrosshairBeVisible() → boolReturns true only while there is a local player controller, the mouse cursor is hidden and the pawn reports Game Only screen control. Any free-mouse or menu mode therefore hides the crosshair.