Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Box Collider 2D Gizmo Missing

Discussion in '2D' started by fireundubh, Jul 7, 2014.

  1. fireundubh

    fireundubh

    Joined:
    Jul 7, 2014
    Posts:
    7
    When I add the Box Collider 2D component to a plane, there is no green boundary box in the scene and there is no collision. But when I add the Box Collider component to a plane, there is a green boundary box and there is collision. I don't understand. What gives?
     
  2. cbothra

    cbothra

    Joined:
    Mar 14, 2014
    Posts:
    125
    Hi check if the BoxCollider2D component is checked in the gizmos list as shown in attached png.

    gizmos.png
     
  3. fireundubh

    fireundubh

    Joined:
    Jul 7, 2014
    Posts:
    7
  4. Vitor_r

    Vitor_r

    Joined:
    May 23, 2013
    Posts:
    93
    Hi, i have 2 suggestions:

    Check if both of the colliders are 2D, u said that with the 3D box collider there is collision so maybe one of them is 3D so it wouldn't collide with the 2D one.

    If your BoxCollider2D component is minimized (like the camera component here) in the Inpector Window the green boundary will not be shown in the scene view.
     
  5. Pyrian

    Pyrian

    Joined:
    Mar 27, 2014
    Posts:
    301
    Um, if your 3D collider is colliding with something and your 2D collider isn't, that rather strongly suggests that "something" is itself a 3D collider.
     
  6. fireundubh

    fireundubh

    Joined:
    Jul 7, 2014
    Posts:
    7
    Here's Box Collider 2D:



    Here's Box Collider (3D):

     
  7. Vitor_r

    Vitor_r

    Joined:
    May 23, 2013
    Posts:
    93
    Try to unrotate the X-axis, set it to 0. Use Y and Z to rotate only.

    And why don't you use Sprite Renderers?
     
  8. fireundubh

    fireundubh

    Joined:
    Jul 7, 2014
    Posts:
    7
    I don't see how to use Y and Z only to get the plane to show in the orthographic view, but I do see the green boundary box with X set to 0.

    I'm just following a tutorial in a book. I'm guessing the book was written before there were 2D components.
     
  9. Pyrian

    Pyrian

    Joined:
    Mar 27, 2014
    Posts:
    301
    Yeah, in 2D you should only rotating on Z, ideally. Setting X to 90, for instance, placed your collider on its side, and a box collider with no width does not exist, nevermind collide with anything.
     
  10. Vitor_r

    Vitor_r

    Joined:
    May 23, 2013
    Posts:
    93
    Yeah Pyrian is right.

    I also suggest you use Sprite Renderers if you wanna make a 2D game, and search some youtube tutorials about 2d development with Unity.
     
  11. GilesDMiddleton

    GilesDMiddleton

    Joined:
    Aug 12, 2015
    Posts:
    91
    Just came across this weird quirk myself - I made a fake button out of a 3d plane ( I just wanted a red box ), when a plane is added, it's flat, so you have to rotate it. When the box collider 2d is added, the points are flat, and haven't been rotated to face the camera. It would be great to be able to rotate the 2d collider separately to the game object. I think my workaround is to use a cube, sprite or 3d collider.