Search Unity

BoxCollider2D: The collider did not create any collision shapes as they all failed verification.

Discussion in 'Physics' started by DarkBladeNemo, Nov 28, 2016.

  1. DarkBladeNemo

    DarkBladeNemo

    Joined:
    Aug 23, 2013
    Posts:
    116
    So I am busy with a 2D top down shooter and have added a follow script to my enemies. I have noticed that whenever they rotate to face right the collider just dies and starts up again if they rotate left.

    Is there any way to fix this? I have tried making the colliders bigger but its not helping.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,428
    Vertex spacing of any polygon needs to be greater than 0.0025 (2.5mm) then the collider cannot create the shape. In the case of a Box, it's a polygon with a single shape so any problem with it gives you the warning in the thread title. For PolygonCollider2D, it's possible that some or all can be like this so you get an appropriate warning.

    It doesn't 'die', you are creating a box that is too small for Box2D to handle. Remember that these are 2D colliders so rotating doesn't rotate into 3D space i.e. in Z so when you rotate, you are simply transforming the vertices in 2D space. By the sound of it, you are rotating it so that the box (at some point) is just a single line of zero width or height during the animation. This is no longer a valid box that can be created by Box2D hence the warning we provide in the inspector.

    The collider is simply warning you of the situation so you can choose to ignore it if it's only for a fraction of time during an animation.
     
    Last edited: Nov 30, 2016
    SimRuJ, jbruce1380 and jegrad like this.
  3. DarkBladeNemo

    DarkBladeNemo

    Joined:
    Aug 23, 2013
    Posts:
    116
    Its a top down shooter. When my enemy turns and faces right and only when that happens the collider gives the error and no longer works. If I turn the enemy to face left it comes back on. The reason why I dont think it makes sense is because if it doesnt work facing the one direction then it shouldnt work when facing the other direction. Can I send you the project so you can have a look and see what I mean?
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,428
    Probably best if you can create a bug report with a simple project attached. Failing that, yes, just give me a link to download it.
     
    jbruce1380 likes this.
  5. bz_apps

    bz_apps

    Joined:
    Aug 19, 2014
    Posts:
    70
    HI, im getting this issue.

    I am spawning a new gameobject with a spriterederer. It is NOT rotated or scaled. I can't click on the sprite. If i disable it and re-enable it, it works and the warning is removed.

    Te collider size id: 1.2x0.9

    The only thing i can think of is the gameobject is being spawning in a 3d space.
     
  6. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,084
    running into this issue with auto generated spriterenderer sprites from layers in the 2019.1 PSDImporter ...
     
  7. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,428
    Never seen a bug report despite asking. Saying you've got the same problem won't solve it either. If you can reproduce the issue then please submit a bug report.
     
    marcularis04 likes this.
  8. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,084
    I ended up just using BoxColliders which seem to work fine with SpriteRenderer. This works out great since I needed to raycast hit in 3D these 2D things.
     
  9. CaptainAfrica

    CaptainAfrica

    Joined:
    Aug 5, 2019
    Posts:
    5
    I have a similar issue, but as far as I know I followed the tutorial (Jared Halpern's Developing 2D games with Unity) and he never mentioned this possible problem, he just said to create the BoxCollider. When I expand it to .0025, the player gets pushed up to the map, possibly because of background objects, and cannot go downwards at all.

    Image attached:
     

    Attached Files:

  10. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,428
    Because your box is obviously too small and Box2D (the underlying physics engine) cannot create such small objects (0.1mm). As I said above, Vertex spacing of any polygon needs to be greater than 0.0025 (2.5mm).
     
    CaptainAfrica likes this.
  11. CaptainAfrica

    CaptainAfrica

    Joined:
    Aug 5, 2019
    Posts:
    5
    Here is a video to document what happens when I set it to .0025. I am not sure if I made the colliders wrong on the background objects or if there is an issue with the collider on the player (using Prefab for the object). Would I have to upload the Unity document to get a precise answer?

     
  12. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,428
    This is off-topic for this thread. Above is the reason why you get the warning which is telling you no shapes could be created. You should start a new thread for your issue.