How to Make Tiles Animated in A Tile Based Building system

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Lazulily

I’ve been making a 2d grid based building system recently, and I followed this tutorial for the building system:
https://godottutorials.pro/godot-strategy-game-tutorial/
My game isn’t a strategy game so it is modified slightly, but not much.

What I want to know is how would I implement an animated tile into this system,
because the tutorial is solely based on static sprites.
What I’ve tried so far is an area2d in it’s own scene, with an animated sprite, and while that part is fine, when I load it to be used by the game, it is stuck in the origin of it’s own scene.
What would I need to do?
Thank you in advance! :smiley:

:bust_in_silhouette: Reply From: dewcked

In Simple projects, use AnimatedSprite.
In Complicated projects, use Sprite(with Sprite Sheet.png) with AnimationPlayer.

see below official godot docs for explanation.

If you want to handle frame changing speed, make sprite’s frame move back and forth, or whatever the property of Sprite, you should use Sprite with AnimationPlayer.

I just tried sprite sheet with animation player but I believe I still have the problem that the sprite is at the position it is at in it’s own scene.

Lazulily | 2021-11-18 07:45

Did you properly added keys in Animation Panel?

Add two keys from there. then set 0 frame on first key. set highest frame on second key. Scale the time if you want and locate first key to left side and second key to right side.

Also, you should check the option I circled with blue. See below

Imgur: The magic of the Internet

If it is hard to place the keys, you can control red circled one.

dewcked | 2021-11-18 07:52

The animation part is not the problem, I am having trouble with the texture/sprite not being where it needs to be but instead is at the center of the project.

Lazulily | 2021-11-18 08:17

Ah sorry. Redesign everything into control node. For the block one, make new control node Scene and put in there. then you can use anchors, and set relative position on screen scale also. This would be like

Main Scene(Control Node)
    Other control nodes and Viewports
            World Scene
                Sprite Scene(Control Node)

and

Sprite Scene(Control Node)
    Sprite Node
    AnimationPlayer Node

dewcked | 2021-11-18 08:37

Awesome thank you, I’ll try it and get back to you! :smiley:

I’m logging off for bed now so I wont get back for a while.
Thanks again!

Lazulily | 2021-11-18 09:23

Nice! Don’t forget to set every control node container’s anchors like this for easy configuration.

top, left = 0
bottom, right = 1

dewcked | 2021-11-18 09:32