I don't understand what exactly the error means

Godot Version

4.6 Stable

Question

Help me understand what is happening in this error. I tried google gemini AI for help, but it suggest me checking the things that are correct.

Errors in question
E 0:00:00:694 create_tile: Cannot create tile. The tile is outside the texture or tiles are already present in the space the tile would cover.
<C++ Error> Condition “!room_for_tile” is true.
<C++ Source> scene/resources/2d/tile_set.cpp:4985 @ create_tile()
E 0:00:00:694 has_alternative_tile: The TileSetAtlasSource atlas has no tile at (11, 0).
<C++ Error> Condition “!tiles.has(p_atlas_coords)” is true. Returning: false
<C++ Source> scene/resources/2d/tile_set.cpp:5437 @ has_alternative_tile()
E 0:00:00:694 has_alternative_tile: The TileSetAtlasSource atlas has no tile at (11, 0).
<C++ Error> Condition “!tiles.has(p_atlas_coords)” is true. Returning: false
<C++ Source> scene/resources/2d/tile_set.cpp:5437 @ has_alternative_tile()

(error repeats for 400 times indexing vector x+1 and y+1)

var source_id = 0
var water_atlas = Vector2i(0,8)
var coast_water_atlas = Vector2i(0,10)
var sand_atlas = Vector2i(0,0)
var grass_atlas = Vector2i(0,2)
var forest_atlas = Vector2i(3,3)


func _ready():
	noise = noise_height_text.noise
	# use base terrain clear to clear any existing blocks
	#base_terrain.clear()
	generate_world()

func generate_world():
	print("Water is at: ", water_atlas)
	print("Forest is at: ", forest_atlas)
	print("Grass is at: ", grass_atlas)
	
	for x in range(-width/2, width/2):
		for y in range(-height/2, height/2):
			var noise_val :float = noise.get_noise_2d(x,y)
			
			if noise_val < 0.0:
				# Water
				base_terrain.set_cell(Vector2i(x,y), source_id, water_atlas)
			else: # noise_val >= 0.0
				if noise_val > 0.3:
					# Forest
					base_terrain.set_cell(Vector2i(x,y), source_id, forest_atlas)
				else:
					# Grass (Only place this if it's NOT forest)
					base_terrain.set_cell(Vector2i(x,y), source_id, grass_atlas)
			

tile map image:

What I checked so far:

  1. ensured that I don’t have any tiles preplaced, checked the tileMapLayer in 2D to check visually. And also checked with .clear() before generation to wipe everything (in the code its now commended out)

  2. Checked tile map to check if I am autogenerating 11th tile, and I don’t think I am.

  3. checked variables (water_atlas etc) if I am pointing incorrectly. I am not.

The only reasonable guess that I have is that I am trying to generate things outside of the scene, but is that a problem? I do want to generate a larger map than my scene just for testing, if thats the case, do these errors mater?

What happens if you don’t call generate_world()?

Hmm, I tried commenting it out and I still get the errors. So I guess its not the code? But then whats the issue?

other than the code in the script and tile layer, there is nothing else to run. And I test by running scene and not the project

Try deleting .godot folder and re-opening the project.

issue still prevails after doing that

Do you have any autoload/global scripts?
Can you post the tscn file?

The only non included code lines in the original question are these:

extends Node2D

@export var noise_height_text : NoiseTexture2D
var noise: Noise

var width : int = 1000
var height : int = 1000

@onready var base_terrain: TileMapLayer = $BaseTerrain

The project itself has two addons (plugins) that are disabled in project files. Addons are:

  • Gaea 2,0
  • WFC

Both are not called in the code.

As for the file upload, the forum does not allow it.

.tscn files are text files, you can just open it in any text editor to copy and paste its content.

Since the issue is about the TileSet, you should also check the bottom panel. When viewing your TileSet there, Is there a yellow circle with an exclamation mark? If yes, click on the three dots menu > “Remove Tiles Outside the Texture”.

2 Likes

Thanks that solved the issue. It was the tiles outside of the texture

1 Like