Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by unity_cma7iR9olN89VA · Aug 20, 2018 at 08:48 PM · collidermathspherecollider

Where can I find the maths implementation for sphere collider

Hi

I want to learn and understand the maths behind how some of unity's features work such as the sphere collider.

Is there anywhere where I can find detailed information as to how the sphere collider actually works?

Or this a secret that Unity have not/will not reveal?

Thanks in advance

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by JVene · Aug 21, 2018 at 11:18 AM

The physics engine used by Unity is PhysX. The source code is available online, but that's going to be a rude awakening to glean the math out of that.


More generally, the subject is quite in depth. The sphere is the simplest collider of all, as it merely uses the radius of the sphere to detect if another sphere is within range. Simply subtract the distance between the centers and check to see if that distance is within the range of the two radii.


It gets more complicated with the object being tested isn't a sphere. The phrase "edge case" literally applies to rectangular objects, and more general mesh shapes work on the various planes the mesh defines. The whole thing is further complicated when continuous mode is enabled, as there is an imaginary capsule or cylinder created on the fly that encloses the previous and current location which is subsequently used (instead of just the sphere) for intersection calculations.


The study is considered to exhaust the undergraduate level, and extends all the way to the graduate level of mathematical study. I say this because it would appear self explanatory that if you're asking then you don't yet have the math background, and if you have the math background you wouldn't need to ask the question. The study is that of math itself, and while you can get the gist of it through a read through to satisfy curiosity, the fact is that since it can't just stop at spheres (even though you want to limit the subject to spheres), this is an all-or-nothing study to get the whole picture of collision testing.


I don't recall the title, but there is a book on the subject of creating physics engines that was an extremely good tour (published around 2008 to maybe 2010). The 'standard' books on this subject come from David Eberly (a PhD and acknowledged authority on the subject), but the author I'm thinking of I think had the first name Ian, but I don't recall. You can find some web based tours by searching for collision testing.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Reivaj28 · Aug 21, 2018 at 10:01 AM

Is this what're you looking for?

https://docs.unity3d.com/ScriptReference/SphereCollider.html

https://docs.unity3d.com/Manual/class-SphereCollider.html

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image unity_cma7iR9olN89VA · Aug 21, 2018 at 10:23 AM 0
Share

No I'm looking for more of the specific calculations that Unity uses to detect collisions for example if that makes sense.

avatar image Reivaj28 unity_cma7iR9olN89VA · Aug 21, 2018 at 10:28 AM 0
Share

Sorry, i couldn't find the maths of the sphere collider, why is it so difficult to find? dammit.

avatar image
0

Answer by FernandoHC · Aug 21, 2018 at 10:55 AM

Some portion of Unity code is exposed on git, so you can search for it yourself there, which classes you're interested in looking at. The maths you're looking for might be pre-compiled on the physics dlls, so might not be possible to expose, but you might find some interesting stuff here: https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/EditorHandles/BoundsHandle/SphereBoundsHandle.cs

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

120 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Raycast visual and moving text possition. 1 Answer

Collider ran twice when the same script is attached to both gameobjects 2 Answers

My SphereCast dont collide with Box collider 1 Answer

How to keep the orientation of an object unchanged when applying forces on its sphere collider? 1 Answer

Invert sphere collider 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges