wojtossfm / godot_scml_importer

MIT License
33 stars 6 forks source link

Issue with animations in cross-fades #24

Open wojtossfm opened 1 year ago

wojtossfm commented 1 year ago

Here's a way to demonstrate the issue I mentioned. I've been tinkering with the animations from CraftPix, and you can reproduce the situation using one of their free downloads, such as the goblin from this set. In the download, you'll find Goblin/PNG/VectorParts, which contains the figure parts as well as Animations.scml.

The animations look fine in isolation; the problem only arises when crossfading between them, as the rotations will sometimes go "the long way around." There are different ways to reproduce the problem, but here's a particular workflow that I was commonly using.

  1. With the SCML importer enabled (and this patch in place), import the goblin parts and animations as described above.
  2. Open the Animations.scml file and create a New Inherited scene when prompted. Save that as a new scene, then remove the inheritance by right-clicking on the root of tree and selecting "Clear Inheritance." This is required to be able to edit the animations.
  3. In the AnimationPlayer node, disable looping on the Idle and Walking animations.
  4. Create an AnimationTreePlayer node. Connect the AnimationPlayer to it. Make its root node into an AnimationNodeStateMachine.
  5. In the state machine, add the Idle and Walking animations, then add automatic transitions to go between them that change at the end of the animation. (That's why the looping was removed above.) Set the animation tree player to Active.
  6. Add a crossfade (e.g. 0.2 seconds) between the animations. Now you will be able to see that the change between animations has the head spinning almost a complete circle.

I hope that helps!

_Originally posted by @doctor-g in https://github.com/wojtossfm/godot_scml_importer/issues/21#issuecomment-1630736014_