title: Unity get distance to edge of Collider2D from within
body: <p>I have a <a href="http://docs.unity3d.com/ScriptReference/Collider2D.html" rel="nofollow noreferrer">Collider2D</a> which moves around within a larger, stationary Collider2D and I'd like to get the distance from the centre of the smaller one to the edge of the larger one along the direction it's travelling in.</p>
  
  <p>My first thought was to use a <a href="http://docs.unity3d.com/ScriptReference/Physics2D.Raycast.html" rel="nofollow noreferrer">Raycast</a> such as:</p>
  
  <pre><code>Physics2D.Raycast(this.transform.position, 
                    this.rigidbody2D.velocity.normalized).distance;
  </code></pre>
  
  <p>But obviously the distance is always 0 as they are already intersecting.</p>
  
  <p>Is there any way to do this?</p>
  
  <p>EDIT: Here is a diagram as requested
  <img src="https://i.stack.imgur.com/TUQ6l.png" alt="diagram"></p>
  
  <p>Both circles are Collider2D objects, the arrow is the direction the smaller one is travelling in and the red x is the point I'd like to find (so I can determine the distance).</p>