- Home /
Is it possible to rotate a BoxCollider2D?
Am I using these 2D box colliders the wrong way?
I'm using sprites with a BoxCollider2D attached for a custom UI, it works fine unless I want to use any of the OnMouse functions that the collider gives me, as the collider doesn't rotate with the sprite. Can this be done or would I be better with a box collider?
Here's what I mean with the collider rotation getting messed up.
Because you are rotating the sprites on X or Y axis(3d rotation). Boxcollider2D supports only Z-axis rotation.
Answer by Tomer-Barkan · Dec 26, 2013 at 07:00 AM
I'm not sure, but from your screenshots it seems like your game is not 2D. If you rotate them on the Z axis, the colliders should rotate no problem, but as soon as you start rotating one of the other axes, it's no longer a 2D game.
If it's not a 2D game, don't use BoxCollider2D, as it was not meant for that, use the regular box collider.
Answer by br.glen23 · Dec 26, 2013 at 04:21 AM
I'm currently working on a 2D game, and from what I can tell, 2D colliders only seem to rotate on the z axis. You'd probably be better off with using a 3D collider for something like that.