Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Stacking 3D colliders

Discussion in 'Editor & General Support' started by dogfacedesign, Nov 12, 2018.

  1. dogfacedesign

    dogfacedesign

    Joined:
    Jan 10, 2016
    Posts:
    70
    I'm not even sure my approach is the "right" one, so I'm all ears here. Here is the use case:

    I have gameobjects which are comprised of 2 different sprites stacked on top of each other, as shown in the little diagram below. The two sprites move around in the gamespace coupled together like they appear. So they sort of "move as one". I need to detect the following events happening between 2 of these gameobjects:

    1) Whenever the blue circles collide.

    2) Whenever the yellow rectangle collides with a blue circle.

    3) Whenever the yellow rectangles collide.

    I tried putting a BoxCollider on both sprites, but I think the colliders for the blue circles are somehow on top (despite my attempts at z-ordering them), so I never trigger a collision with the yellow rectangles. These need to be 3D colliders, due to a constraint by a 3rd party package I'm using. If the 2 colliders have different z-orders, I'm not sure that the yellow rectangles would EVER collide with a blue circle, correct?

    At any rate, the use case seems pretty straightforward, but I'm pulling out my hair a wee bit. What approach would you guys take, from a collider standpoint?


     
  2. dogfacedesign

    dogfacedesign

    Joined:
    Jan 10, 2016
    Posts:
    70
    I have a new approach that I am working on now. I changed the circle shape and its BoxCollider to a sphere and a sphere collider. Since the game is top down, it looks the same anyway. I think now I should be able to use Physics.OverlappedSphere a bit, but not quite sure.