Search Unity

Question Collision Problem with Multiple Tilemaps

Discussion in '2D' started by thesimpleone, Mar 16, 2023.

  1. thesimpleone

    thesimpleone

    Joined:
    Mar 10, 2023
    Posts:
    7
    I'm creating a top-down farming sim, and one of the features is, of course, getting more plots for farming. I have a script to do this with SetTiles that uses a rule tile so the tilemap can continually expand using the same tile. However, this script uses cellBounds to get the size of the tilemap, uses that to make an array of positions that are moved outward one grid square, and places tiles in that array.

    Screenshot 2023-03-16 192051.png
    Because I'm using cellBounds, and I haven't found a way to start cellBounds at a specific point, I have the rest of the movable area on a separate tilemap that overlaps with the first tilemap to give the illusion of one tilemap.

    Screenshot 2023-03-16 192033.png

    The problem is the edges of the tilemaps have collisions so the player avatar runs into those collisions where the tilemaps overlap. Also, Unity is giving collisions for tiles I've set to "none" but that's a separate issue.

    The three solutions I've come up with are:

    1) using code I'm not aware of to use cellBounds with a minimum starting point for both axes, allowing me to only have one tilemap and avoid the whole thing.

    2) Have a way to "skip" over the collisions.

    3) One I'm not thinking of cause I'm tunnel-visioned.

    Any thoughts?