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
  4. Dismiss Notice

Question Blocked by invisible Box Collider2D.

Discussion in '2D' started by wizenchiko, Dec 31, 2021.

  1. wizenchiko

    wizenchiko

    Joined:
    Dec 6, 2019
    Posts:
    10
    I have RuleTile with GameObjects (they v got Collider and Rigidbody). When I destroy them and move in some direction, the side ones block my somehow. Why is that ? Also I have Physics Material 2D with 0 Friction
    attached on that player. Sometimes it doesnt block me. https://imgur.com/a/52tHYRJ video here. upload_2021-12-31_16-54-13.png
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,780
    Are you sure? Run the game and when you get into a blocked state, pause the game, delete the thing you THINK is blocking you, and see. If you're still blocked then it's something else.
     
  3. wizenchiko

    wizenchiko

    Joined:
    Dec 6, 2019
    Posts:
    10
    next block (that on the left down corner) is blocking me, but it shouldnt coz its in the same layer/position.
     
  4. TimeLex

    TimeLex

    Joined:
    Sep 5, 2021
    Posts:
    6
    I could imagine that Rigidbody moves the player in such a way that it is still a small piece in the other collider or that there are rounding errors. You could fix this by determining the distance (or x and y difference) between the two colliders and then seeing whether the distance is smaller than a small constant value. If so, you can briefly deactivate the other collider so that it no longer blocks the player.
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,546
    The diagram isn't really that clear TBH but are you simply talking about "ghost contacts" where you're assuming that separate physics shapes should somehow automatically be handled as a continuous surface even though they are discrete shapes? In short, they won't be if that's the assumption.

    In 2D physics, the only continuous surface available are physics shapes known as edges. They can be produced by the EdgeCollider2D or the CompositeCollider2D (in outline mode). This is why, often, you will see a TilemapCollider2D being selected to use a CompositeCollider2D in outline mode because this produces continuous edges from the discrete shapes of the tilemap. This essentially removes these "ghost contacts".

    Its effect can be reduced by using a CapsuleCollider2D shape for characters but this only reduces the effect because of the rounded bottom of the shape so catching the side of an adjacent collider shape doesn't stop the character dead.

    A nice little description of the issue can be found here.

    Maybe though, this isn't what you're talking about in which case, nothing to see here. ;)
     
    wizenchiko likes this.
  6. wizenchiko

    wizenchiko

    Joined:
    Dec 6, 2019
    Posts:
    10
    Next tile which didnt even touch the player was blocking. So as guy above me said, i changed box collider of player to capsule. Thanks