Goutte / godot-addon-animated-shape-2d

Godot addon to animate a CollisionShape2D along with the frames of an AnimatedSprite2D. Useful for making changing hitboxes, hurtboxes and hardboxes. Comes with an Editor, making things easy.
MIT License
130 stars 1 forks source link

Support for metadata on shape frames #10

Closed Goutte closed 8 months ago

Goutte commented 10 months ago

This only needs a public endpoint to access the current shape frame, if any.

Rationale

I'm also using this plugin to add extra information on each animation frame, and it's been delightful for things like is_before_slash on startup frames.

Using this in AnimatedShape2D, and a get_meta on the result when not null:


func get_current_shape_frame() -> ShapeFrame2D:
    var animation_name := self.animated_sprite.get_animation()
    var frame := self.animated_sprite.get_frame()
    return self.shape_frames.get_shape_frame(animation_name, frame)

The metadata records are added in the Editor, as metadata of a single ShapeFrame2D. Shallow and deep copies seem to work as expected.

image

You don't have to use a special metabox to use Metadata, you can use the hitbox directly for example, but I've found it to be less messy.

Goutte commented 10 months ago

See d5313849cae6066d5dc15382777ec39687d33e26 .