Animating 2D sprites in Godot cna be done in two main ways:
- Using
Sprite
andAnimationPlayer
nodes and a spritesheet - Using
AnimatedSprite
node and individual frame sprites
Collision Shapes
Warning
While
AnimationPlayer
can make the collision shape follow the sprite, I don’t know if it’s possible to achieve similar effect usingAnimatedSprite
.
A possible workaround is to create a bigger shape encompassing full range of motion or few individual hitboxes that are cycled through onframe_changed
signal.
To animate the collision shape together with the sprite, the position of the CollisionShape
has to be tracked (Node2D → Transform → key icon on the right)
example: Animation layer and collision combat