Set_cell func not working for cellpos over (6, 6)

Godot Version

godot 4.2.2

Question

I have a script that draws tiles based on its width and height variables, but for some odd reason it won’t draw any tiles over Vector2i(6 , 6).

Code:

If height = 3 and width = 3:

if height = 10 and width = 10:

^ the square of tiles should be 10 tiles long and 10 tiles tall but it is only 6 long and 6 tall.

1 Like

If I understand the set_cell() function correctly, the coords argument is for where you wanna place a tile on the TileMap, while the atlas_coords argument decides which tile out of the atlas of the TileSet is being placed. I am guessing that this chess pattern in your TileSet is only 6 tiles big, so when you reach 7, the function is grabbing empty tiles and won’t continue on further.

You could change your code to the following. Hope this helps. :>

for x in width:
	for y in height:
		$"../TileMap".set_cell(0, Vector2i(x, y), 0, Vector2i((x + y) % 2, 0), 0)
2 Likes

Thank you! I feel dumb now, I understand what atlas coords are but I failed to realize that if one of the vars were over the atlas tilesize that it wouldn’t draw anything :grinning:

1 Like

Oh, it’s quite alright. ^^ Tunnel vision or stupid copy and paste mistakes can happen to anybody; no matter their skill level. :> And asking for help is what the forum is there for. ;D

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.