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
  3. Dismiss Notice

Showcase Order of the colliders

Discussion in 'Scripting' started by SevickV, May 11, 2024.

  1. SevickV


    Feb 29, 2024
    Hi all.

    I made a small demo that show the order of the objects detected by Physics.OverlapSphere.
    Hope it shows all aspects clear enough.

  2. ArachnidAnimal


    Mar 3, 2015
    When running this simulation, order will change if I rotate the system around the origin. And sometimes the order will just change again after a few seconds even with not moving or rotating anything.
  3. Kurt-Dekker


    Mar 16, 2013
    Yes... if the documentation does not say "will always be in this order," (and it doesn't say that), the order will NEVER be guaranteed, even if you happen to notice it is always in a particular order on your machine.

    You run it on a different day, different machine, different reimport, different build target, different astrological zodiac sign and the order will be different.

    In other words, if you rely on some particular unpromised order, your software is almost certain to fail, even if it hasn't yet.
    ArachnidAnimal likes this.