poohcom1 / godot-animated-sprite-2-player

A Godot addon to convert animated sprite frames to animations in an animation player.
https://godotengine.org/asset-library/asset/1605
MIT License
41 stars 3 forks source link

SpriteFrames individual frame duration is not honored in resulting animation #5

Closed hsandt closed 1 year ago

hsandt commented 1 year ago

Context

I need to add some lag at the beginning of my attack animation for telegraphing, but since I'm using a spritesheet made by someone else, I cannot just draw my own extra sprites, so I'm just extending the duration of the first frames.

To do this, there are three ways: a. on the SpriteFrames, increase the Frame Duration setting of individual sprites (what we are interested in here) b. on the SpriteFrames, add copies of the same sprites after itself c. on the resulting AnimationPlayer animation, move the sprite keys after the sprite to extend later in the timeline

Issue

With method a., I noticed that the resulting animation still gives the same duration to every sprite frame, ignoring the Frame Duration setting.

Sprite Frames setup: image

Resulting animation: image

Request

When pressing Import, we should multiply the duration of a sprite frame in the resulting animation by Frame Duration.

Workaround

As a fallback, I tried method b., which works, but has two disadvantages:

  1. There is no "Duplicate after" button so it's cumbersome to add extra copies of the same frame: you must copy-paste it but the pasted frame is added to the end of the SpriteFrames, so you must then move it left repeatedly until it reaches the same place as the original frame.
  2. You can only multiply the total duration of the sprite by an integer number this way, equal to the number of identical sprites. Whereas Frame Duration allows fractions like x2.5.

As a second fallback, I tried method c., which works, but next time I press the Import button, it will replace my adjusted animation and all sprites will revert to having the same duration. Plus, the old "don't replace" mode from Godot 3 version has been removed, so I don't have a way to prevent overwriting my custom changes while still adding new animations (it would be useful to combine the old and new behavior with a hybrid mode "don't replace existing tracks" for these situations; but that would be the topic of another issue for proposal).

poohcom1 commented 1 year ago

Ah, thanks for the notice. I haven't been using AnimatedSprite recently, so I didn't know about the frame duration setting. I'm a bit busy at the moment so I'll have to take a look into it later, a PR would be welcomed in the meantime.

I also like the idea for the hybrid "don't replace existing tracks". The main reason I removed the option was that initially it was meant to prevent none sprite-related tracks from being replaced. I hadn't thought about the use case where we wouldn't want the sprite tracks themselves from being replaced, so an option might be needed.

hsandt commented 1 year ago

OK, I need this today so I'll try some PR.