I understand that a simple sphere collider in Unity is a raycast in all directions with a certain length. How many Raycast events does a sphere collider trigger? At what degree increments are the rays cast?

  • \$\begingroup\$ Can you cite a source for your understanding that a sphere collider is a raycast in all directions? This would be a very strange way to implement this collision primitive. \$\endgroup\$ – DMGregory Nov 6 '18 at 11:02
  • \$\begingroup\$ Sorry, just some guy on gamedev. I wouldn't know who anymore. \$\endgroup\$ – AzulShiva Nov 6 '18 at 11:29
  • 1
    \$\begingroup\$ I'd caution against trusting such hearsay. There's a lot of superstitious claims out there about gamedev generally and Unity in particular that don't stand up to experiments in practice. \$\endgroup\$ – DMGregory Nov 6 '18 at 11:35
  • 1
    \$\begingroup\$ Sphere colliders are not a finite number of raycasts. They're calculated as a distance. If you subtract a sphere collider's radius and add that radius to all other colliders, the sphere can be treated as a point object (which is far, far faster to compute). \$\endgroup\$ – Draco18s no longer trusts SE Nov 6 '18 at 15:48
  • \$\begingroup\$ Welp.. If someone wants to edit the question, go ahead. Otherwise it seems like I gotta delete it. I wanted to program a cone shaped collider myself using raycasts and I wondered what would be faster, a few raycasts or a sphere collider with an angle. I guess I'll just test it. \$\endgroup\$ – AzulShiva Nov 6 '18 at 22:08

Not always a raycast. Unity3D's collision is based on PhysX and it support multiple types of geometry queries:

  • raycasts test a ray against a geometry object.
  • sweeps move one geometry object along a line to find the first point of intersection with another geometry object.
  • overlaps determine whether two geometry objects intersect.

How unity technologies implements every one of them is not exposed as far as i know.

in-depth doc on PhysX

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.