Attaching Box Collider 2D to a 3D object

I was experimenting with getting a 2.5D game working where the game was running in 3D but collisions occur on a 2D plane. I was manually creating 3D box colliders and projecting them onto an orthographic camera near fustrum plane however I ran into some really strange problems which may (or may not) be a bug with Unity:

http://answers.unity3d.com/questions/588344/transformposition-of-child-object-not-working-as-i.html

I just downloaded the latest version of Unity and noticed all the 2D stuff added and immediately had the idea of adding 2D box colliders to my objects instead of the above method.

Upon adding box colliders and resizing them I noticed that they show up in the positions I wanted in the editor view. However I can’t seem to figure out how to get collisions working with them. I don’t want any physics interactions as these are only meant to detect collision so I am using triggers.

I set isTrigger to true for all 2D colliders and added isKinematic RigidBody2D to the object as well. I then implemented onTriggerEnter2D(Collider2D collider) in the script on the same object as the rigidbodies. It doesn’t seem to register any hits though, am I missing something? Is the behaviour undefined if I have no sprite attached?

Also I noticed that the x/y scale for the box collider 2D is not 1:1 on the screen plane, what determines the scaling ratio? Finally I assume that all 2D colliders work on the same plane (view plane or one parallel to the viewplane), is this correct?

That won’t work unless the Rigidbody2D isn’t kinematic (yes that’s different from the 3D physics engine). Having a sprite attached or not isn’t relevant since sprites are only used for display and don’t affect the physics engine. 2D colliders only work on the x/y plane; not related to the view.

–Eric

Oh okay thanks. I am curious what you mean by X/Y plane. Is that the z=0 plane in world coordinates? It doesn’t appear to be that. Are you referring to X/Y on the screen as viewport coords?

I experimented more with adding 2D box colliders to objects and noticed that it does not position as I want it to all the time.

I have a parent object with RigidBody2D with 2 child objects which are offset to the parent and each having a single Box collider 2D. The images below show the exact setup I have:

I want the boxes to appear centered on the child transform positions (the front and back of the vehicle). Also notice how the size I set is x:5 y:9 to get a square, why is this? Am I using the 2D stuff all incorrectly? I want collisions to occur if boxes look to be overlapping from the screen point of view even though the objects may be far away from each other in terms of the z axis away from the screen.

The X/Y plane as in the world X axis and the world Y axis. It definitely is that; 2D physics don’t depend on camera positions in any way. The Z axis is not used.

–Eric