Hi! I have this code where if i swipe down i want to activate and deactivate some colliders and the oposite if i swipe up but it does not seem to work.Can someone tell me what is wrong with it?Thanks
void Update()
{
if(Input.touchCount > 0)
{
Touch touch = Input.touches[0];
switch(touch.phase)
{
case TouchPhase.Began:
{
startPos = touch.position;
up.enabled = false;
down.enabled = false;
break;
}
case TouchPhase.Ended:
{
float swipeDistVertical = (new Vector3(0,touch.position.y,0) - new Vector3(0,startPos.y,0)).magnitude;
if(swipeDistVertical > minSwipeDistY)
{
float swipeValue = Mathf.Sign(touch.position.y - startPos.y);
if (swipeValue > 0)//up swipe
{
down.enabled = false;
up.enabled = true;
}
else if (swipeValue < 0)//down swipe
{
up.enabled = false;
down.enabled = true;
}
}
break;
}
}
}
}