Search Unity

2D RayCastAll TileMapCollider problem

Discussion in '2D' started by RidgeWare, Nov 22, 2018.

  1. RidgeWare

    RidgeWare

    Joined:
    Apr 12, 2018
    Posts:
    67
    Hi,

    I need to be able to detect *all* tilemap walls (and regular objects) a RaycastAll passes through, but it only appears to detect the first of that TileMapCollider type. So, for example, if it passes through 3 objects and 2 of them are of the same tilemap collider tile, the array of hits will only contain 2 objects instead of 3. (The closest of the 2 wall tiles + the other 1).

    Which doesn't work for me.

    Am I reading this right or is this the way RayCastAll is supposed to work? Would seem a bizarre limitation if that were true.

    If so, what would be my alternative? Using the exit point of the first hit and creating a new RaycastAll from that position? And then putting them all together somehow to build up a proper list of tilemap tiles in that path?
     
    Last edited: Nov 22, 2018