Search Unity

Physics.CheckBox()

Discussion in 'Wish List' started by metervara, Jan 14, 2009.

  1. metervara

    metervara

    Joined:
    Jun 15, 2006
    Posts:
    203
    There's Physics.CheckSphere() and Physics.CheckCapsule() so why not?

    /Patrik
     
  2. bem13

    bem13

    Joined:
    Jul 1, 2010
    Posts:
    64
    I have also noticed this missing. It would be nice if there were a CheckXXX for each collider type.

    One reason is that I was wanting to test if an object could be put at a certain location without intersecting anything, and before spawning the object itself or activating its scripts.

    Without this feature I think Im faced with some sort of complicated mechanism of spawning a stand-in object with all the same colliders,and waiting one physics iteration to see if there are any collision events? Apart from the bother of delayed testing, Im not sure this is robust. For example what if the first object is moving. If I parent the new object to it I dont think I get the collisions, and if I try to keep it with the right relative position across frames through some other means, I suspect update order or such could lead to collisions that are not meaningful.

    Another useful thing I could do with a CheckBox is to effectively test against a plane. This would let me test if something was bounded by an arbitrary convex hull, for example.

    Ah well.. after writing this message I just realised it wouldnt actually be that tough for me to write my own test for a box against the unity primitive colliders anyway. I dont care about mesh colliders for my particular case.
     
  3. goy

    goy

    Joined:
    Jul 15, 2012
    Posts:
    10
    Asked that myself two days ago too.

    I need to spawn some buildings, but need to check against obstacles, like my soldiers, before spawning is possible.

    Of course I could have done some Workaround, but every idea I came across was a dirty solution.
    So I didn't do anything, because I just want some simple Physics.CheckBox() and nothing more complicated.

    Why is something so simple missing?
     
  4. Pulpsoft

    Pulpsoft

    Joined:
    Jul 5, 2012
    Posts:
    11
    Can't you get the same effect with Bounds.Intersects() ?
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Well you can use a box trigger and parse the collision stay messages. It's not going to be usable outside fixedupdate though.