Search Unity

Ignore collision between projectile and specific tile in TIlemapCollider2D

Discussion in '2D' started by Zargy, Apr 21, 2018.

  1. Zargy

    Zargy

    Joined:
    Jul 13, 2014
    Posts:
    17
    Pretty much the title. I am trying to implement destructible tiles in my game, and projectiles that penetrate through several tiles based on how much health they have left, and the tiles themselves have a hardness stat which subtract from the projectiles health. The issue I'm running into is I can't use Physics2D.IgnoreCollision with the tilemap collider, because that will make the projectile shoot through the rest of the tilemap without triggering any more collisions. But if I don't ignore the collision then my bullet will bounce off the tilemap since it can't exist inside the collider. Does anyone have any suggestions for this issue?
     
  2. N_Murray

    N_Murray

    Joined:
    Apr 1, 2015
    Posts:
    98
    I'm not sure how your tiles are set up but have you tried removing the rigidbody if there is one and using trigger events instead of collisions? this way you could pass through the collider and with an if statement in the trigger event to check the projectiles health you could destroy if you want to or just deduct the tiles hardness stat from the projectiles health.