A simple question about Click, Press & Hold

Hi, I want to click Mouse left button to do action, and long press(Hold) to move my character forward.
But the mouse event just press and release action, I can use them for long press: when button pressed set the scalevalue=1 to “addMovementInput” node in BP, and set it back to 0 when button released.
Oviously it conflict with the Mouse click, we usually triggrt it from “press” or “release”.
So anyone could help? Thanks a lot!

Try using a Gate Node. Have Event Tick enter the gate, keeps the flow constant. On Leftclick the gate will open and remain open till leftclick is released. Add a DoOnce node to do some action once till button is released to reset the DoOnce.

So in my example, Event Tick is trying to open the gate, when the left mouse is pressed the gate opens and Event Tick continues the flow until left mouse button is released. The frame the left mouse button was pressed on will flow into a sequence node which first goes into the DoOnce node and fires off the custom event Some Action, one time only until its reset. The sequence node stays active and continues the Event Tick flow into a custom event Move To Location. Which will continue to flow until the left mouse button is released.

Once the left mouse button is released, a sequence is used to reset the DoOnce and closes the gate. Stopping the Event Ticks flow through the gate.

Rinse, Repeat.

Note:
If you are using the touch input, the left mouse button gets used up for that input. So instead of using the Left Mouse Button node, use the same idea as above but insert the gate, sequence and DoOnce nodes in the flow of the input
touch.

Hope this makes sense, Good Luck!

~

1 Like