Using Unity's new input system, I would like to detect a start touch and and end touch. Using these, I'd like to compute the distance and direction for the camera to move, so the camera moves with a "swipe". However, I am having trouble figuring out how to detect these touches in Update().
Pseudocode would be:
private void Update() {
// get start position
// get end position
MoveCameraOnSwipe()
}
I've figured out what goes in MoveCameraOnSwipe(), or how to move the camera using a target position and direction. The only part I can't figure out is how to use the new input system to capture the start and end values in Update.
I could try to read the values directly, but not sure how that would work:
We could return values from the touch using this method, where Screen Controls is player input:
public Vector2 PrimaryPosition()
{
return screenControls.SwipeMap.PrimaryPosition.ReadValue<Vector2>();
}
Then in Update() - would I do something like:
screenControls.SwipeMap.PrimaryContact.started += context => StartTouchPrimary(context);
screenControls.SwipeMap.PrimaryContact.canceled += context => EndTouchPrimary(context);
But this doesn't seem quite complete. Any help would be appreciated.