Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question is unity have a spatial hash grid which is working on background

Discussion in 'Physics' started by tugrulsubekci, Nov 11, 2022.

  1. tugrulsubekci

    tugrulsubekci

    Joined:
    May 30, 2022
    Posts:
    5
    I really curious about collision detection and raycast of unity. Is unity have a spatial hash grid which is working on background
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,580
    Most if not all physics engines use a Broadphase which is a spatial acceleration structure to speed-up the detection of potentially colliding things; before the Narrowphase performs the more costly exercise of determining if they are actually colliding. There's plenty of material online about this technique, nothing Unity specific is required.

    Also, there are multiple physics engines used by Unity though.
     
    tugrulsubekci likes this.
  3. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,967
    Bounding volume hierarchies (BVH), sweep and prune (SAP) and regular grids are popular broad phase structures. Each one has strengths and weaknesses. Unity's built-in, default 3D physics engine is PhysX -widely used by other game engines- which I believe uses an algorithm called "automatic box pruning" by default but can also use SAP. Docs may help: https://gameworksdocs.nvidia.com/Ph...igidBodyCollision.html#broad-phase-algorithms

    Note that in recent Unity versions, you can choose which broad phase algorithm to use in the Physics settings: https://docs.unity3d.com/2022.2/Documentation/Manual/class-PhysicsManager.html
     
    tugrulsubekci likes this.