title: Swipe trees in a given direction using events and delegates
body: <p>I'm sending events out like this in ScreenInputManager.cs, so that trees in my scene will move in the direction of a given swipe:</p>
  <pre><code>public delegate void SendSwipe(string swipeDirection);
  public event SendSwipe moveGameItems;
  
  private void Update()
      {
          if (Touch.activeFingers.Count == 1) {
              
              // other code here not related to this
              TriggerSwipe(startPos, endPos);
          }
      }
  
   private void TriggerSwipe(Vector2 start, Vector2 end)
      {
              if (Vector2.Dot(Vector2.left, direction2D) &gt; directionThreshhold)
              {
                  moveGameItems(&quot;left&quot;);
              }
  
              if (Vector2.Dot(Vector2.right, direction2D) &gt; directionThreshhold)
              {
                  moveGameItems(&quot;right&quot;);
              }
          }
      }
  
  </code></pre>
  <p>Then, in another script, I'm subscribing to those events, like this:</p>
  <pre><code>private ScreenInputManager inputManager;
  
      private void OnEnable()
      {
          inputManager.moveGameItems += MoveTree;
      }
  
      private void OnDisable()
      {
          inputManager.moveGameItems -= MoveTree;
      }
  
      private void Awake()
      {
          inputManager = ScreenInputManager.Instance;
      }
  
      private void MoveTree(string direction)
      {
          
          // code here
      }
  
  </code></pre>
  <p><strong>Problem:</strong> However, MoveTree is called continuously - as long as the swipe continues. I think this could because TriggerSwipe() is in Update, but then again, when I Debug.Log in the function itself, it only seems to called it is actually swiped.</p>
  <p><strong>What I want:</strong></p>
  <p>I want to call MoveTree only when the screen is swiped. I have tried using boolean flags, etc., but the problem is I also want to be able to interrupt MoveTree with a swipe in the other direction if I need to.</p>
  <p>So the input from the delegate has to be steadily received, but when it moves in a specific direction, it should move in that direction once until it has to move in another direction.</p>
  <p><strong>What I've tried:</strong></p>
  <p>I have tried boolean flags, using &quot;yield return&quot; in coroutines, etc., but I don't seem to be able to get it so it can be interrupted to go in the other direction if I need to.</p>