title: How to correctly spawn Gameobject exactly on top of another object?
body: <p>Working on a <code>2D</code> game in Unity and I'm having difficulties trying to spawn a block exactly on top of a platform in my game. I don't want the block to look like it's floating or overlapping the platform.</p>
  
  <p>I can't seem to get the calculation correct.</p>
  
  <p>I currently have this code:</p>
  
  <pre><code>public GameObject blockPrefab;
   public GameObject platform;
   public GameObject dummyBlock;
  
   // Use this for initialization
   void Start () 
   {
       float platformSize = platform.GetComponent&lt;Renderer&gt;().bounds.size.y;
       float blockSize = dummyBlock.GetComponent&lt;Renderer&gt;().bounds.size.y;
       Debug.Log(platformSize.ToString());
  
  
       GameObject test = (GameObject)Instantiate(blockPrefab,
                                                 new Vector3(platform.transform.position.x, platform.transform.position.y + platformSize/2, platform.transform.position.z),
                                                 Quaternion.identity);
   }
  </code></pre>
  
  <p>The problem with this is that it spawns the block in a way that it overlaps the platform which means my calculation for the block's y position is wrong.</p>
  
  <p>I'm still getting used to working with Unity's world coordinate system, so yeah. Anybody know how to solve this?</p>