Part of what was mentioned in #5965, putting as separate issue for maintainability.
Yes, we do. Actually, we can already make animations with tilemaps, as evidenced by Minilens:
func _process(delta): # Move the acid
acid_animation_pos = acid_animation_pos + delta
if(acid_animation_pos > acid_animation_time):
acid_animation_pos = acid_animation_pos - acid_animation_time
level_tileset.tile_set_region(2, Rect2(64-64*acid_animation_pos/acid_animation_time,0,64,64))
Unfortunately, this is very hacky, and also forces update of _all_ quadrants, as opposed to just quadrants which have the animated tile.
(terminology note: a TileMap
is made up of cells. Each cell is of a specific type, know as a tile.)
After discussing the issue with @ArcFutahito on IRC, we agreed on the following idea:
TileSet
should be made animateable somehow (probably via SpriteFrames
)AnimationPlayer
and AnimatedSprite
do. It might be useful to seek it as well.About the implementation, I'm still not sure if we should keep cells with animations on separate canvas items, as to save some redraws. So, this is also something we might want to discuss.
I have made some animations with AnimationPlayer changing texture region of individual tiles (or all the tileset), using frames could be more easy but depends on the tilemap, not regular tiles are allowed and using the region will be the best option.
@eon-s well, if you check that minilens example again, it was exactly what we did -- changing the region.
All cells with the same tile id would get the same frame at a given point in time; a cell added later would still get the same frame as other cells with the same tile.
May an integer phase value be added to this feature? Phase value of each tile will mean
# n: current frame number
# p: phase value
show frame[n + p] for this tile
It can be useful I think. Will it make additional performance impact?
@hubbyist if it is per-cell, it would probably require an additional byte per cell or so. Performance might be impacted if we run into CPU cache issues, but not way too much. In case we are doing this, we would probably get per-cell pausing of animation as well.
This would be incredibly useful for when importing Tiled maps as well using the existing (and future) plugin from the asset lib (I think @vnen is the author?).
This will be possible in 3.1 with the new AnimatedTexture
(coming soon).
What is the status of the issue? Is it already solved in current master?
No, I totally forgot about this. Sorry, thanks for the reminder ^^
Any idea on the release date of this? Really looking forward to it :)
With the new AnimatedTexture, can this be closed?
I think so yeah. Haven't used them, but from reduz's comments, it should work.
Going to close as it was implemented.
As reduz mentioned on twitter, the AnimatedTexture won't work for AtlasTexture. Now I wouldn't want to assume my ways to be the best practice but i am assuming that lots of people (if not most) working with the TileMap are using TextureAtlasses to manage lots of tiles.
What would now be the way to go if we consider the AnimatedTexture to solve our animated tiles issue?
Should we keep every frame in a separate image file if a tile is animated or am I missing a better workflow?
you can animate the region of the atlas texture with an animation player selecting the texture of the tileset resource from the tilemap node then you add a modulate key frame so the tilemap updates, I'm not sure if this is efficient but it works.
Most helpful comment
This will be possible in 3.1 with the new
AnimatedTexture
(coming soon).