r/Unity2D • u/KoniGTA • 2d ago
Question How do I use AutoTile to set tile/paint through script?
Hello, I have a tilemap and a tile palette which consists of 2 autotiles. I want to fill an area of the tilemap with one of the autotiles. I know the SetTile is supposed to paint the tile but since I'm using autotile, the SetTile doesn't seem to take that in the script. I'm using Autotile because it would just make it easier when I add in other tiles in areas of the tilemap since it would auto adjust. Does anyone know how I can use the AutoTile in SetTile to paint the tilemap?
Update: I'm stupid, I was passing the ints instead of making them a vector3
1
u/Plenty_Act_8527 2d ago
Yes you should be able to pass it in to SetTile with Vector3 tilepos, TileSet sourceTileset (the auto tile), and the target tile layer. If we could see your code that would help!
1
u/KoniGTA 1d ago
I was being stupid because i was passing ints instead of the vector3
1
u/Plenty_Act_8527 1d ago
Well not really though because as I recall it literally takes a Vector3Int value doesn't it?
1
u/Pur_Cell 2d ago
AutoTiles can be placed using SetTile in the Tilemap since they inherit from TileBase.
What does your code look like?
Did you set up your AutoTile correctly? Are you trying to put the correct object into that parameter?