Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Bug all Physics2d.Boxcast variants are broken

Discussion in '2021.1 Beta' started by astrokoala, Mar 12, 2021.

  1. astrokoala

    astrokoala

    Joined:
    Mar 23, 2016
    Posts:
    21
    Physics2D.BoxCast
    Physics2D.BoxCastAll
    Physics2D.BoxCastNonAlloc

    these are all broken, that never takes distance parameter into account.

    Consider the following code
    Code (CSharp):
    1. var size = new Vector2(1,1)
    2. var angle = 0f;
    3. var distance = 5f;
    4. Physics2D.BoxCastAll(origin, size, angle, Vector2.down, distance, layers);
    this code will fail to detect anything within the 5 distance, and will only detect something touching that 1 x 1 size

    in contrary to this code
    Code (CSharp):
    1. var size = new Vector2(1,1)
    2. var angle = 0f;
    3. var distance = 5f;
    4. Physics2D.CapsuleCastAll(origin, size, CapsuleDirection2D.Vertical, angle, Vector2.down, distance, layers);
    the capsule cast version works properly and correctly detects everything in 5 distance away
     
  2. astrokoala

    astrokoala

    Joined:
    Mar 23, 2016
    Posts:
    21
    To anyone having the same problem
    and to the unity team

    I found that if you change the
    Default contact offset
    setting in Project Settings/physics2d
    from
    0.001
    (the default value) to
    0.01
    , it then starts to work properly

    Please take a look into this
     
  3. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    991
    As with all bugs, please file a bug report with a repo project if you can.
     
    LeonhardP likes this.
  4. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,497
    Hi @astrokoala,

    Based on your description of the problem we couldn't find anything wrong. If you're still affected by this problem, as @Chris-Trueman suggested, please submit a bug report with a reproducible so we can have a look at your exact use case.
     
unityunity