Search Unity

Physics2D Overlap Circle not working with Edge Collider 2D

Discussion in '2D' started by malec2b, Nov 25, 2013.

  1. malec2b

    malec2b

    Joined:
    Aug 6, 2012
    Posts:
    1
    Hi all,

    I've currently got my game set up with edge colliders for obstacles in the level geometry. I then have my character object check where it's about to move with Physics2D.OverlapCircle so that it won't move into any collisions. However, it only recognizes the collision if I collide with the left-most line of the edge-collider, and I'm not sure what's causing this.

    Thanks
     
  2. honigkuchen

    honigkuchen

    Joined:
    Nov 24, 2013
    Posts:
    7
    Yap, got the same bug in the beta with polygon colliders :/
     
  3. AlexGK

    AlexGK

    Joined:
    Jul 31, 2013
    Posts:
    38
    I'm experiencing the same bug, and it hasn't been fixed yet. Any plans to do so?
     
  4. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    Have you filed a bug report?
     
  5. AlexGK

    AlexGK

    Joined:
    Jul 31, 2013
    Posts:
    38
    Don't really want to complain, but they usually take a lot of time to answer those.
     
  6. AlexGK

    AlexGK

    Joined:
    Jul 31, 2013
    Posts:
    38
    Bug report sent. Hope to receive an answer. Will share if I do.
     
  7. AlexGK

    AlexGK

    Joined:
    Jul 31, 2013
    Posts:
    38
    Bump

    No response yet
     
  8. khoggatt

    khoggatt

    Joined:
    Jan 8, 2014
    Posts:
    1
    Have you received a response yet? I'm stuck on this same issue.
     
  9. AlexGK

    AlexGK

    Joined:
    Jul 31, 2013
    Posts:
    38
    Sorry, not such luck :/

    Will fill another bug report
     
  10. AlexGK

    AlexGK

    Joined:
    Jul 31, 2013
    Posts:
    38
    Just to be clearer about my issue:

    I'm doing a platformer game prototype, by using Playmaker and TK2D.

    TK2D uses EdgeColliders for its tile maps. I run a script to detect whether my character is touching the ground or not, and
    changing his state on Playmaker accordingly. Obviously, it doesn't work.

    However, if my character falls on top of a platform with a BoxCollider attached to it, the landing event fires up.
    I know there are alternatives, like using raycasting. But I think it's unncecesary, this should be working, as that method is used in examples and in their live training sessions.
     
  11. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    There's really nothing wrong with using Raycasting though, it's even what was used in the original Sonic games on the Genesis. It's a pretty classic technique that doesn't take much compute power at all, plus it allows for your character to begin moving to it's grounded animations on the frame it's actually about to hit, instead of hitting and then changing.
     
  12. Cricket88

    Cricket88

    Joined:
    Nov 17, 2013
    Posts:
    7
    Hi to all, just wanna say I bumped into the same issue...
    have you found some solution?
    ty
     
    Last edited: Jan 26, 2014
  13. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    Hi,

    I have not seen a bug report for this but reading this it instantly triggered a thought of what it might be. A quick check this morning confirmed what the problem was. The bug was that the overlap checks for circle/area do not iterate the shape-index and only checks the first edge. This isn't a problem for any other shape type but when the EdgeCollider2D was added, it was critical that all edges were checked until an overlap was found.

    I am fixing this right now and it will be in a future release.

    Thanks for the heads-up.
     
  14. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    Excellent news! :)
     
  15. Cricket88

    Cricket88

    Joined:
    Nov 17, 2013
    Posts:
    7
    Thanks for the reply, that's a good new.

    From the little i presume to have understood, using edge collider with circle overlap is quite more expensive than on other 'linear' colliders. Does this iteration on the edges may become heavy for a recurring check on multiple edges? like that for jumping on a broken ground may be? (I'm referring to last unity 2d tutorial and its 'jumping technique')
    Does, for example, raycast could be a better solution?

    thanks in advance
     
  16. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    Using an overlap check on an edge collider can be more expensive that a ray-cast, however, how much more expensive it is relates to your set-up. A simple check on your end with the profiler will tell you if it's prohibitively expensive or if it's a cost your project is willing to bear. In most cases I think you'll no notice the difference.
     
  17. Cricket88

    Cricket88

    Joined:
    Nov 17, 2013
    Posts:
    7
    thank you very much :) I'll profile these two options
     
  18. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    Any news on this issue? it seems to be still present and I recently updated Unity.
     
  19. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    No change in the news, it was fixed 2 weeks ago. Unfortunately, due to the way releases work, a fix one week won't mean it'll be in a public release the next.
     
  20. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    I know this comes with the dangers of using 3rd party tools, hopefully it gets submitted soon. In the meantime I would really appreciate if you or anybody could point me to a work around? I know some people mentioned ray casting but I am unsure on how to make that work for this case specifically.

    Thanks again.
     
  21. d13f00l

    d13f00l

    Joined:
    Dec 8, 2013
    Posts:
    2
    Doh....also awaiting this fix. I'm working on a 2d platformer and am turning on and off collision layers for jump-through platforms. I need to be sure a player isn't inside a platform before turning the collision layer back on else they get stuck. The player is using a circle collider so I thought I'd use Physics2D.OverlapCircle to check if the player is in the middle of a platform before turning on the layer collision again. It was acting weird. Found this thread. Thanks. I guess I will just try raycast. Or maybe try a box collider.

    Edit: I need to read the thread better, OverlapArea is also affected.
     
    Last edited: Feb 20, 2014
  22. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    Just do a raycast from the top of your 2D collider bounds to the bottom, on both sides, and if either are true, keep the layer collision turned off.
     
  23. d13f00l

    d13f00l

    Joined:
    Dec 8, 2013
    Posts:
    2
    Yeah that's exactly what I ended up doing. Seems to work fine, finally. This is like my 5th or 6th attempt at this, each way I tried I hit a wall or missing feature but finally raycasting seems to work.
     
  24. RyuK

    RyuK

    Joined:
    Feb 12, 2014
    Posts:
    55
    Any news on ETA for the fix? Do I have to wait for the next major release or is it included in a minor updates?
     
  25. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    Physics2D.OverlapCircle not working on PolygonCollider2D ?
     
  26. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    It's not working for me. how did you fix it ???