title: Change a variable in a coroutine
body: <p>I'm developing an AI and I'm wanting to use a coroutine to help delay the enemies decision making. </p>
  
  <p>Issue is, I can't figure out how to make my MoveZ variable change outside of the script. As soon as the functions close, it drops the value for MoveZ. </p>
  
  <p>How can I make it so that way after the coroutine passed it saves the MoveZ variable for reference later within the script? </p>
  
  <p>I asked on the Unity Scripting forum and they directed me to use lambda syntax, but it doesn't solve my issue.</p>
  
  <p>My code calling the coroutine</p>
  
  <pre><code>StartCoroutine(FindRun((i)=&gt;{MoveZ = i; Debug.Log(MoveZ);}));
  </code></pre>
  
  <p>Declaring the coroutine</p>
  
  <pre><code>IEnumerator FindRun(System.Action&lt;int&gt; callback){
  
      yield return new WaitForSeconds(.1f);
      if (Distance &gt; 3){
          callback(1);
      }
      else if (Distance &lt; 2) {
          callback(-1);
      }
      else {
          Travelling = false;
      }
  } // Closes FindRun
  </code></pre>
  
  <p>Any insight would be greatly appreciated!</p>