0 votes

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! :D

Godot version version 3.4
in Engine by (30 points)

1 Answer

0 votes

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

see below official godot docs for explanation.

https://docs.godotengine.org/en/stable/tutorials/2d/2d_sprite_animation.html

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.

by (236 points)

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.

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

https://imgur.com/a/461gAgO

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

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.

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

Awesome thank you, I'll try it and get back to you! :D

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

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

top, left = 0
bottom, right = 1

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.