Axis Double Tap (Unreal Engine 4)
The template projects in the Unreal Engine 4 use axis inputs for movement. This is done so that you can use a gamepad's analogue stick for movement. The tricky bit, in comparison to input actions, is that the axis fires each frame and you need to read out the value. The execution needs to trigger on the value rising over a threshold and not the execution tick.
This is about how you would integrate the
AxisDoubleTap. Since we want to
preserve "normal" movement the sequence splits out to the
on the one side and the
AxisDoubleTap selector on the other. The
AxisThreshold (0.75) and
DogeTimeout (0.4) are variables that are
exposed on the Character, so that they can easily be tweaked later on.
As you can see, I have not yet implemented the doge, so for now we will just print "Doge Left" and "Doge Right".
AxisDoubleTap selector works in three stages. The first stage
AxisSplit) take the axis value and separates it into three execution pulses.
Positive pulse is when the value is above the threshold, the
pulse is when the value is below the negative threshold and the
pulse when the value is between the positive and the negative thresholds.
The second stage is a flank trigger. That is the continuous execution pulse
is converted into one single pulse. This is done with the help of a
node. The impulse is routed into the that node and only passes through once,
any further pulses are dropped. Only until the input goes back to neural,
DoOnce is reset and thus a new pulse will be let through.
The third stage is the
DoubleTap selector. This basically take the pulses
and only emits a pulse if two consecutive pulses came in.
AxisSplit is quite straight forward. Two chained
Branch nodes each
comparing the value to the threshold and the inverted threshold.
DoubleTap is basically implemented through a
DoN node. The
two execution pulses through, but the flowing
Branch only evaluates to true
when the second pulse is emitted. The
Delay is used to ensure that two pulses
come without too much delay. If the delay is completed it will reset the
for a new round of impulses.
So you have it, once it is spelled out like this, it seems obvious.