Animable TliesMap Usign AnimatedTexture wont work

Godot Version

4.2.2 & 4.3 RC2

Question

So i have a animated terrain like 3 frames similar at this:

All tiles share the same parameters:

  • 3 animation variant per tile
  • Same duration time per Tile
  • Same offset in the Spritesheet

i see this tutorial that help doing the proper way right now How to create an animated tile in Godot 4's tilemaps | foosel.net

But i have a some issues right now:

  1. Doing the tutorial, there a lot of tiles to animate: for each type of surface there 48 animable tiles, so its become a repetitive process to quickly.
  2. AnimatedTexture was deprecated but was the more effective way before.
  3. AnimatedSprite its incompatible with TileMaps & TileMapLayers

There 2 options i wouldn’t try yet:

  • Make Custom Flipbook Shader for the tile system and apply to each tile.
  • Make an Script that automate the Tutorial Way

So. my question its what the best approach in this case? i missing something?

Well i tried to automate via a tool Script and it works!

here is the code in my case:

@tool
extends EditorScript

##select custom tileSet to animate
const tileset: TileSet = preload("res://enviroment/tilesets/base_01/base_01_tilseset_og.tres")
const tile_path_save: String ="res://enviroment/tilesets/base_01/base_01_tilseset_result.tres"


##params:
const FRAME_DURATION: float = 0.16
const FRAME_OFFSET: Vector2 = Vector2(0,7)
const NUMBER_OF_FRAMES: int  = 3


func _run():
	var source: TileSetSource = tileset.get_source(0)
	if source is not TileSetAtlasSource:
		return
	source = source as  TileSetAtlasSource
	
	for i in source.get_tiles_count():
		var id: Vector2i = source.get_tile_id(i)
		source.set_tile_animation_columns(id,1)
		source.set_tile_animation_separation(id, FRAME_OFFSET)
		source.set_tile_animation_frames_count(id, NUMBER_OF_FRAMES)
		for j in source.get_tile_animation_frames_count(id):
			source.set_tile_animation_frame_duration(id,j, FRAME_DURATION)
		
		
	var result = ResourceSaver.save(tileset.duplicate(),
		tile_path_save,
		ResourceSaver.FLAG_BUNDLE_RESOURCES)
	if result == OK:
		print("tileset saved in: " + tile_path_save)


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