- Home /
Swipe controller can't detect short swipes
So I have a game where my player moves along Z axis and has a trigger box in front of him. When other object enters the trigger box zone the swipe input is turned on and player can swipe in certain direction to move that object in that direction and when that object leaves the trigger box or was moved the input turns off.
The problem is that the program works fine, but if I make a short swipe, like barely move my mouse the swipe is not registered. How can I fix this ?
private Vector2 startTouch, endTouch, swipeDelta;
void Update()
{
swipeLeft = swipeRight = swipeUp = swipeDown = false;
if (InputOn)
{
#region Mouse Inputs
if (Input.GetMouseButtonDown(0))
{
isDragging = true;
startTouch = Input.mousePosition;
}
else if (Input.GetMouseButtonUp(0))
{
endTouch = Input.mousePosition;
if (startTouch != endTouch)
{
isDragging = false;
InputOnRight = false;
Reset();
}
}
#endregion
}
}
private void Reset()
{
startTouch = swipeDelta = Vector2.zero;
isDragging = false;
}
I don't get your script, is it complete ? When do you use swipeDelta for example ?
Answer by LascauxMontignac · Aug 15, 2020 at 12:44 AM
@AarnasS75 I test your code and works fine here.. Did you try in which version of unity?
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Dice Value 1 Answer
When I move and then rotate my direction doesn't change. 0 Answers
Removing instantiated objects?? 1 Answer