How to rotate or flip tiles through script?

I am generating tiles automatically to build a path. To save on the number of tiles needed and simplify things I want to rotate or flip the tiles so that the path can line up.

I don’t see any way to this through TileBase.

Ideally I would do something like:
road1.rotate but even road1.flipx and road1.flipy would work.

Is there any way to do this using the current tilemap system?

1 Like

Update, modifying the example:

I am able to get tiles to rotate as I wanted but now my tilemap collider doesn’t work.

More detail:
The composite collider is created just fine but it puts a line between the sprites.

I tested rotating my image in photoshop then saving as a different sprite and that works, so I know the edges line up.

Workaround found:
Change the tile gap to -0.00001 and everything works.

1 Like

I got my collisions to work by putting this line at the end of the GetTileData function.

tileData.colliderType = ColliderType.Sprite;

As for the gaps. There are various ways to get around this. What worked best for me was to save each tile individually and setting the Mesh Type from Tight to Full Rect. Also having pixel snap enabled in the sprite material.

However, I cannot get rotations to work as you did after I set the tiles.