title: Unity Raycast problems
body: <p>Well I'm trying to make a circle(with dynamic position) and another circle that SHOULD not pass through the first one --- like in the image below </p>
  
  <p>The reason why I am doing this way is because there can be a lot of other objects on the big one.</p>
  
  <p><img src="https://i.imgur.com/q7EGTIW.png" alt="circle image"></p>
  
  <p>but the problem is that Physics.Raycast is not always detecting my sphere:</p>
  
  <p><img src="https://i.imgur.com/feh5ZmA.png" alt="broken circle image"></p>
  
  <p>the blue lines are raycasts</p>
  
  <p>Basically what i do is raycast through the whole big circle and find out where the smaller one is. </p>
  
  <p>Here is my code for detecting objects on the big circle:</p>
  
  <pre><code>void GetCollisions () {
      Angle FixedRenderAngle, k;
      RaycastHit hit;
      Vector3 p1, p2;
      float d, d1, radius;
  
      for ( int i = 0; i &lt; Radiuses.Count; i++ ) {
          if ( Angles[i] == null )
              Angles[i] = new List&lt;Angle&gt;();
  
          radius = Radiuses[i];
          FixedRenderAngle = 360f / (float)NumberOfCalls;
          AnglesLast[i] = 0;
          Angle j = 0f, pj;
          bool exception = false;
  
          for ( int l = 0; l &lt; NumberOfCalls; l++) {
              j+= FixedRenderAngle;
              pj = j - FixedRenderAngle;
              p1 = pj.PointByRadius ( radius );
              p2 = j.PointByRadius ( radius );
              Debug.DrawRay ( p1, p2 - p1, Color.cyan, 3f );
              if ( Physics.Raycast ( p1, p2 - p1, out hit, Vector3.Distance ( p1, p2 ) ) ) {
                  d = Vector3.Distance ( p1, p2 );
                  d1 = Vector3.Distance ( p1,hit.point );
                  k =  pj + (j -pj) * (d1/d); 
  
                  AddToAngles ( ref k, i );
              }
  
              if ( Physics.Raycast ( p2, p1 - p2, out hit, Vector3.Distance ( p1, p2 ) ) ) {
                  if ( AnglesLast[i] == 0 ) exception = true;
  
                  d = Vector3.Distance ( p1, p2 );
                  d1 = Vector3.Distance ( p1,hit.point );
                  k =  pj + (j -pj) * (d1/d); 
  
                  AddToAngles ( ref k, i );
              }
          }
  
          if ( exception == true ) {
              Angle tmp = Angles[i][AnglesLast[i] - 1];
              for ( int l = AnglesLast[i] - 1; l &gt; 0 ; l-- )
                  Angles[i][l] = Angles[i][l-1];
              Angles[i][0] = tmp;
          }
      }
  }
  </code></pre>
  
  <p>Angle is a class with float numbers representing degrees(0 to 360) and it's function PointByRadius is returning a Vector3 representing the location where should it be on a circle based on the angle and with a given radius.</p>
  
  <p>Did I do something wrong or there is something that i don't know about raycasts? Any help would be appreciated. (Of course any other method for this would help)</p>