Documentation confusion - composite bindings

I’m a little confused by the current documentation. I’m assuming it is out of date OR that I’m missing something really obvious. Looking at Composite Bindings doco here.

myAction.AddCompositeBinding("Axis")
    .With("Positive", "<Gamepad>/rightTrigger")
    .With("Negative", "<Gamepad>/leftTrigger");

I could only find AddCompositeBindings in InputActionSetupExtensions rather than in InputAction. Something similar with InputActionMap.AddAction(…).

The following partially works although it is missing the name and causes issues with the asset editor.

InputActionSetupExtensions.AddCompositeBinding(action, "Dpad") // Or "2DVector"
  .With("Up", "<Keyboard>/w", "Keyboard&Mouse")
  .With("Down", "<Keyboard>/s", "Keyboard&Mouse")
  .With("Left", "<Keyboard>/a", "Keyboard&Mouse")
  .With("Right", "<Keyboard>/d", "Keyboard&Mouse");

For simple bindings I can do the following, but how do I do that for AddComponsiteBinding?

InputActionSetupExtensions.AddBinding(action, "<Gamepad>/leftStick", "Gamepad").WithName("LeftStick");

The methods in InputActionSetupExtensions are defined as C# extension methods which makes it possible to invoke them directly on an InputAction object even though they are not defined in the InputAction class.

We’ll fix the problem of it not assigning names to composites.

1 Like