Search Unity

Using 2D colliders in 2.5D game

Discussion in 'Physics' started by HosseinArabbeigi, Jul 28, 2019.

  1. HosseinArabbeigi

    HosseinArabbeigi

    Joined:
    May 7, 2014
    Posts:
    16
    Im using BoxCollider2D in my 3D objects and i want change colliders rotation to make BoxCollider2D horizontal (my game is top down), but when i did change game object rotation, BoxCollider2D did become a line instead of squre.

    Whats wrong??
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
    2D colliders are just that, 2D and only operate in the XY plane. They cannot be rotated away from this plane or into arbitrary orientations. Rotating them simply produces a different projection onto the XY plane. They only have one degree of rotational freedom and that's around the Z axis.

    If you want to use 2D colliders in a top-down view then your view needs to be looking along the Z axis i.e. the same axis as when you select the 2D view in the editor.

    Hope this helps.
     
    Last edited: Jul 29, 2019
    HosseinArabbeigi likes this.
  3. HosseinArabbeigi

    HosseinArabbeigi

    Joined:
    May 7, 2014
    Posts:
    16
    Thanks Melv, your answer helped me too much. i will use it in XY Plane.
     
  4. the_real_ijed

    the_real_ijed

    Joined:
    Dec 6, 2012
    Posts:
    8
    Sorry for necro-ing the thread...

    Does this effectively mean that a top down 2D collision game cannot use vector3 forward/right or Navmeshes then? Since both of those are limited to XZ and 2D collision to XY.

    I'd prefer to avoid the overhead of 3D collision if possible, but I'm working off old forum posts (like this one!) so not sure if my information is still correct.