title: How do I create an object to move between two positions in unity, using C#, and why is my code not working?
body: <p>I have this piece of code right here that should make the block object move between the <code>startPos</code> and <code>endPos</code> objects, but something is wrong about it and I don't know what.</p>
  
  <pre><code>void FixedUpdate()
  {
      if (block.transform.position == startPos.transform.position)
      { 
          check = false; 
      }
  
      if(block.transform.position == endPos.transform.position)
      { 
          check = true;  
      }
  
      if (check == false)
      {
          block.transform.position = Vector3.Lerp(block.transform.position, endPos.transform.position, .03f);
      }
  
      if (check == true)
      { 
          block.transform.position = Vector3.Lerp(block.transform.position, startPos.transform.position, .03f);     
      }
  }
  </code></pre>
  
  <p>At some point the block will reach <code>endPos</code>, and then on its way back to <code>startPos</code> it will stop, because the functions will be executed simultaneously. But how is this possible because my if's right there should not allow this to happen?</p>