void Update() { if (!hasStarted) { switch (swipeArea.GetCurrentSwipeDirection()) { case SwipeDirection.RIGHT: currentHeadDirection = Vector2.right; headSegment.InitiateMove(); headSegment.SetMoveDirection(currentHeadDirection); hasStarted = true; break; case SwipeDirection.UP: currentHeadDirection = Vector2.up; headSegment.InitiateMove(); headSegment.SetMoveDirection(currentHeadDirection); hasStarted = true; break; case SwipeDirection.DOWN: currentHeadDirection = Vector2.down; headSegment.InitiateMove(); headSegment.SetMoveDirection(currentHeadDirection); hasStarted = true; break; } } if (canInput) { switch (swipeArea.GetCurrentSwipeDirection()) { case SwipeDirection.RIGHT: if (currentHeadDirection == Vector2.right || currentHeadDirection == Vector2.left) { break; } currentHeadDirection = Vector2.right; headSegment.SetMoveDirection(currentHeadDirection); canInput = false; break; case SwipeDirection.LEFT: if (currentHeadDirection == Vector2.right || currentHeadDirection == Vector2.left) { break; } currentHeadDirection = Vector2.left; headSegment.SetMoveDirection(currentHeadDirection); canInput = false; break; case SwipeDirection.UP: if (currentHeadDirection == Vector2.up || currentHeadDirection == Vector2.down) { break; } currentHeadDirection = Vector2.up; headSegment.SetMoveDirection(currentHeadDirection); canInput = false; break; case SwipeDirection.DOWN: if (currentHeadDirection == Vector2.up || currentHeadDirection == Vector2.down) { break; } currentHeadDirection = Vector2.down; headSegment.SetMoveDirection(currentHeadDirection); canInput = false; break; } } }