Hello guys:
I’m new to the input system, and I’m not quite sure if this is a bug or not, I’m currently using Input System 1.4.4, with the touchscreen inputs.
So I’m trying to make a “charged move” here, the player would need to hold the screen for a short period of time to charge, and then the “tank” will keep moving towards the player’s finger location until the player lifts his/her finger from the screen.
In order to do that, I created a PrimaryTouchDetection action to check whether the player is pressing on the screen.
_touchInput.Touch.PrimaryTouchDetection.performed += ctx => TouchDetection();
_touchInput.Touch.PrimaryTouchDetection.canceled += ctx => TouchUp();
At first, I thought the performed and cancelled callback would just work as GetButtonDown and GetButtonUp, so once the player is holding the screen for enough time, the TouchDetection() will be called and the “Tank” will start to move to the player, and when the player is no longer pressing the screen, the TouchUp() will be called to reset everything.
And everything just worked until today I checked the documentation again, and I found that the definition of the cancelled callback for Hold interaction is this :
“Control magnitude goes back below pressPoint before duration (that is, the button was not held long enough).”
So according to the documentation, the “cancelled” callback should never been invoked after the “performed”, but why in my case it just “work as I expected”?
And if this is a bug, what is the proper way to listen to the “Press” action ends?