Polling actions
Polling actions is one of the two main ways to respond to actions using the recommended workflow.
Polling refers to the act of repeatedly checking the status or value of an action. This is in contrast to using callbacks which are only triggered when an action is performed.
The code required to poll an action depends on the action type, and whether you want to read the action's values or use the interaction state instead.
Poll value-type actions
To poll an action whose type is Value or Pass-through, use:
You must use the corresponding type that matches the action's control type's value. For example, ReadValue<Vector2>() for a 2D axis.
Poll button-type actions
To poll an action whose type is Button, use:
Buttons have no applicable value other than whether they are pressed or released.
Poll using interaction phases
Actions have interaction phases which can be either Waiting, Started, Performed or Canceled. The interaction phase changes depending on the action's interaction type, if one is assigned, or the default interaction otherwise. You can poll an action's interaction phase using the following methods:
Examples
Polling actions example with a 2D axis and a button action
This example shows polling two actions in Update.
The Move action is a value-type, and the Jump action is a button-type.
It looks like the sample you are looking for does not exist.
Polling actions example using interaction phase
This example uses the Interact action from the default actions, which has a Hold interaction to make it perform only after the bound control is held for a period of time (for example, 0.4s):
It looks like the sample you are looking for does not exist.
Polling button actions example
This example uses three actions called Shield, Teleport, and Submit (which are not included in the default actions):
It looks like the sample you are looking for does not exist.