title: Changing the parent of an instantiated object changes its position, how do I keep it at the instantiated position
body: <p>I want to instantiate an object to a given position, then change its parent to another gameobject, but keep the instantiated object in the same position I've instantiated it. Instead, the object changes its position to the object I'm parenting to.</p>
  
  <p>I've got this empty GameObject the script is applied to. I am instantiating an object to another empty GameObject's position, that works fine. I then set the instantiated object to be a child of another empty GameObject, because I want to move the GameObject I've used as instantiating position without moving the instantiated object, because I want to keep instantiating that object to a new position. But that fails, the object I've generated moves itself to the position of the 3rd empty GameObject, the one I'm setting as a parent.</p>
  
  <pre><code>GameObject theTile = Instantiate(thePrefab, spawningZone.transform);
  theTile.transform.SetParent(parentObj.transform);
  </code></pre>
  
  <p>After setting the new parent, the instantiated object moves itself to the parent's position.
  I've tried multiple ways of doing this, but for every method I've tried, the same thing was happening, the instantiated object moved to the new parent's position.
  These are the alternative methods I've tried:</p>
  
  <pre><code>GameObject theTile = Instantiate(thePrefab, spawningZone.transform);
  theTile.transform.parent = transform.parent;
  </code></pre>
  
  <p>;  </p>
  
  <pre><code>GameObject theTile = Instantiate(thePrefab, spawningZone.transform);
  theTile.transform.SetParent(parentObj.transform, false);
  </code></pre>
  
  <p>;</p>
  
  <pre><code>Vector3 originalPos = spawningZone.transform.position;
  GameObject theTile = Instantiate(thePrefab, spawningZone.transform);
  theTile.transform.SetParent(parentObj.transform);
  theTile.transform.position = originalPos;
  </code></pre>