title: C# Unity 3D - Is there a way to make custom raycast shapes?
body: <p>I have a ship that will shoot targets, but cannons on the right side should never try to shot at targets on the left side of the ship. Thus I have created sectors using the <code>SignedAngle</code> function, this works fine for testing, but its also kind of broken as you can see from the visualization below.
  I have tried using <code>boxcast</code> but alas it also doesnt work for this use case.</p>
  <p><a href="https://i.stack.imgur.com/KUt3E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KUt3E.png" alt="img1" /></a></p>
  <p>The above image visualizes what my script does, but this is not a solution to my problem. As targets close to the side and front of the ship will be outside the sector, for clarification what I mean, see picture 3.
  <a href="https://i.stack.imgur.com/QqX67.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QqX67.png" alt="img2" /></a></p>
  <p>This second image shows what happens when we increase the angle, we can now detect more targets, but we have 2 big incorrect sectors marked in red which shouldnt be there.
  <a href="https://i.stack.imgur.com/eo80X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eo80X.png" alt="img3 Correct" /></a></p>
  <p>Finally, this is how I think it should look, its still a cone, but the big difference is that it starts with a wide bottom, thus it resolves the problem Im having with the current SignedAngle function which determines everything from a single point in the middle.</p>
  <p>This is the script for assigning targets to the correct list according to which sector they are in:</p>
  <pre><code>foreach (Transform target in EnemyListManager.instance.enemyShips.ToArray())
          {
  
              if (Vector3.Distance(transform.position, target.position) &gt; ship.mainGunCaliber.range)
                  continue;
  
              Vector3 toTarget = target.position - transform.position;
              print(Vector3.SignedAngle(hullParent.forward, toTarget, Vector3.up));
  
              if (Vector3.SignedAngle(hullParent.forward, toTarget, Vector3.up) &gt;= bowMinAngle &amp;&amp;
                  Vector3.SignedAngle(hullParent.forward, toTarget, Vector3.up) &lt;= bowMaxAngle)
              {
                  if (!bowTargets.Contains(target))
                  {
                      RemoveFromOthers(target);
                      bowTargets.Add(target);
                      print(&quot;added target to Bow&quot;);
                  }
                  continue;
              }
              if (Vector3.SignedAngle(hullParent.forward, toTarget, Vector3.up) &gt;= sbMinAngle &amp;&amp;
                  Vector3.SignedAngle(hullParent.forward, toTarget, Vector3.up) &lt;= sbMaxAngle)
              {
                  if (!sbTargets.Contains(target))
                  {
                      RemoveFromOthers(target);
                      sbTargets.Add(target);
                      print(&quot;added target to SB&quot;);
  
                  }
                  continue;
  
              }
              if (Vector3.SignedAngle(-hullParent.forward, toTarget, Vector3.up) &gt;= aftMinAngle &amp;&amp;
                  Vector3.SignedAngle(-hullParent.forward, toTarget, Vector3.up) &lt;= aftMaxAngle)
              {
                  if (!aftTargets.Contains(target))
                  {
                      RemoveFromOthers(target);
                      aftTargets.Add(target);
                      print(&quot;added target to Aft&quot;);
  
                  }
                  continue;
              }
              if (Vector3.SignedAngle(hullParent.forward, toTarget, Vector3.up) &gt;= psMinAngle &amp;&amp;
                  Vector3.SignedAngle(hullParent.forward, toTarget, Vector3.up) &lt;= psMaxAngle)
              {
                  if (!psTargets.Contains(target))
                  {
                      RemoveFromOthers(target);
                      psTargets.Add(target);
                      print(&quot;added target to PS&quot;);
  
                  }
  
              }
          }
  </code></pre>
  <p>Any help would be appreciated on how to tackle this problem!</p>
  <p>Thank you.</p>