Search Unity

Fast moving rigidbodies not colliding with TilemapCollider2D.

Discussion in '2D' started by BlockFade, Feb 27, 2018.

  1. BlockFade

    BlockFade

    Joined:
    Jan 28, 2017
    Posts:
    25
    In my game, I have a high velocity rigidbody with the collision detection set to Continous.
    When using a Tilemap with the TilemapCollider2D component, the rigidbody passes through the tiles.

    The tilemap & the rigidbody are both on the default layer.
    The tilemap's collider is not set as a trigger.

    Is this a bug?
    If so, is there a workaround for this?

    This is game breaking.
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi @BlockFade

    This happens with 3D too.

    When you have very high velocity, physics fixed update will place object first in front of your wall, then behind it in next step/tick. So your object "tunnels" through the wall.

    Maybe use raycast as secondary check, if you want to make sure you object doesn't pass some obstacle.

    Also, are you really sure your object has to move that fast...?
     
  3. BlockFade

    BlockFade

    Joined:
    Jan 28, 2017
    Posts:
    25
    I'll try using raycasts for collisions.

    I need to have my object move fast for a drift ability he player has.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,455
    There's nothing special about a TilemapCollider2D over any other collider. Like them, continuous col-det will only work if you're letting the Rigidbody2D move via its own velocity or if you're using Rigidbody2D.MovePosition. Trying doing the same using an EdgeCollider2D (if you're using TilemapCollider2D "outline" mode) or a PolygonCollider2D (if you're using TilemapCollider2D "polygon" mode).
     
    BlockFade likes this.