How do I effectively create a tile set from a sprite sheet?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By spacingnix
:warning: Old Version Published before Godot 3 was released.

So, as the title says I’m trying to create a tileset to use on a tileMap automatically, since the standard method would simply consume too much of my time everytime I needed to provide new tiles (be it the map or enemies).

I’m using Godot for the first day on version 2.1.1 64 bits on Linux

I’ve tried hacking up a script which ended being similar to this (which I’m now trying to use):

tool extends Node2D

export(bool) var reset = false setget onReset

var root =  get_tree().get_edited_scene_root()
var floor_texture = preload("res://assets/tileset/floor1.png")

func _ready():
	# Called every time the node is added to the scene.
	# Initialization here
	pass
	
func onReset(isTriggered):
	if (isTriggered):
		reset = false
		var w = floor_texture.get_width() / tileSize
		var h = floor_texture.get_height() / tileSize

		for x in range(w):
			for y in range(h):
				var tile = Sprite.new()
				add_child(tile)
				tile.set_owner(self)
				tile.set_name(str(x+y*w))
				tile.set_texture(floor_texture)
				tile.set_region(true)
				tile.set_region_rect(Rect2(x*tileSize, y*tileSize, tileSize, tileSize))
				tile.set_pos(Vector2(x*tileSize+tileSize/2, y*tileSize+tileSize/2))
				tile.set_owner(root)

To the root node of the tileset scene, but can not figure out how it’s not working…

Searching for other methods I stumbled into addons on this list, which pointed me to this solution already done by a senior on the community. I placed the plugin in addons folder in my project structure (as needed by version 2.1.1), activated it, but the option shown in the github image are not appearing in the 2d scene. I’m lost.

Am I missing something? I’ve read the getting started tutorial about three times now and the GDscript very carefully but I’m somehow still missing something.

That plugin is old and will need some fixes to fit on 2.1.x.

Try using this one from the asset lib, has multiple ways to create tilesets (from files, from a single tileset, et cetera), it also adds collision polygons and occluders when making or by selecting the created sprites.

http://godotengine.org/asset-library/asset/9

You can search and add it to your project from the assetlib inside Godot or download and add manually.

eons | 2016-12-26 03:34

:bust_in_silhouette: Reply From: spacingnix

That was it, thank you so much :)))