Search Unity

List of object in bounding box

Discussion in 'Wish List' started by ChrisPaulson, May 27, 2011.

  1. ChrisPaulson

    ChrisPaulson

    Joined:
    Nov 16, 2010
    Posts:
    43
    Simple but powerful feature which I was used to when using another engine.

    It would be nice to do: -

    gameobjectList = gameObject.find( bounding volume, object type );


    This would be a help when a scene has lots of objects. The only current work around at present is to store the object list in a KD or quad tree, or iterate everything and take a big performance hit.
     
  2. DwarfCavern

    DwarfCavern

    Joined:
    Mar 10, 2011
    Posts:
    31
    Hi, I am trying to find a way to simply list which GameObjects intersect or are contained within given .bounds, but am not able to. Is this what you are referring to? Should I stop looking? :(
     
  3. ChrisPaulson

    ChrisPaulson

    Joined:
    Nov 16, 2010
    Posts:
    43
    This is not exactly what I'm asking for, you could do something like this:-

    Code (csharp):
    1.  
    2. foreach gameobject in scene
    3.  if gameobject.bounds.intersects( myObject.bounds) then
    4.      do whatever...
    5.  endif
    6.  
    however the loop on gameobject is inefficient if you have a big scene and many objects. Check out: -

    http://unity3d.com/support/documentation/ScriptReference/Bounds.Intersects.html


    I presume Unity must store it's scene in some sort of quad tree/kd tree/oct tree and it would be nice to have access to it's efficiency and get lists of objects in a bounding box.
     
  4. DwarfCavern

    DwarfCavern

    Joined:
    Mar 10, 2011
    Posts:
    31
    Thanks, but happily I've found a totally different approach so that I don't have to do any tests for my problem :)