Recipes
Input mapping actions bindings keyboard mouse gamepad touch
Whenever the player needs to control something. All input flows through ONE
InputProfileComponent per controllable entity. Movement, jump, fire, and look are just actions in its actions array.Use this for
mapping keys, mouse, gamepad, or touch to gameplay actions; movement axes; jump and fire buttons; look sensitivity; per-action prediction
Not for
transient editor or menu shortcuts (client-local, not this component); camera math (see first-person-controls)
Pairs with: First-person camera movement and mouselook controls, Third-person follow camera and platformer jump movement, Combat damage health and respawn scripting
The recipe
- Attach
InputProfileComponentwithproject_add_component(project.entity.component.set):{ "type":"InputProfileComponent", "version":1, "actions":[ ... ] }. - Each action object needs:
key(stable id),valueType(one ofboolean,float,vector1d,vector2d,vector3d,world_target,screen2d,trigger,composite),contexts(for example["gameplay"]),triggers,processors,policy,prediction, andbindings. policy.effectSystemroutes the action:movement,action,script, orlook. Setmovementfor WASD,lookfor mouselook (add thepolicy.lookblock),actionfor verbs (fire, interact).prediction.modeisclient_predicted(responsive movement),client_only(look), orserver_authoritative(anti-cheat verbs).- A binding maps sources to the action:
{ "id":"binding.move.wasd", "sources":[{ "device":"keyboard", "control":"KeyW", "event":"down", "modifiers":[] }, ...], "triggerOverrides":[], "processors":[], "priority":0 }. Valid devices:keyboard,mouse,gamepad,touch,xr. Valid events:down,up,press,move,axis,sample. - For a jump button, add a
booleanaction with akeyboardSpacedownbinding. For gamepad, add a second binding withdevice:"gamepad". For mobile, add atouchbinding to the same action; one action, many devices. - Shape raw input with
processors[].kind:deadzone,curve,invert,sensitivity,clamp,normalize,axisComposition,stickComposition,threshold,quantize. Shape timing withtriggers[].kind:pressed,released,held,tap,doubleTap,hold,chord,continuous,continuous_delta,step,cancel.
Pitfalls
- Trigger and processor
parametersare discriminated bykind. Aholdtrigger needsparameters.durationMs(1..60000); acurveprocessor needsscale/exponent. Mismatched parameters are rejected; you cannot edit one leaf at a time and stay valid. policy.look.sensitivityDegis clamped 0.001..45 and pitch bounds -89..89.versionis readonly to most surfaces; keep it 1 unless you are migrating.- The removed
InputActionDeclarationComponent,InputBindingSetComponent, andInputContextStackComponentall fold into this one component; never author them.
Verify
engine_get_component_schemaonInputProfileComponentfor projected field contracts before writing a binding. Device-dependent control checks live inInputSourceSpecSchemainpackages/ecs/src/index.ts; use the native mouse binding shown in the first-person-controls playbook for look input.simulation_runto confirm the action fires on the mapped control.