derkork / godot-statecharts

A state charts extension for Godot 4
MIT License
797 stars 43 forks source link

Having trouble with animation state trees #106

Closed gaengberson closed 5 months ago

gaengberson commented 5 months ago

First off, this is a great tool. As a new dev it is helping me a great deal.

The trouble I am running into is with nested animation trees.

I can get this extension to manage animation state transitions easily when the animation tree root is classed as a state machine.

But if the animation tree root is a blend tree with state machines within it, I cannot effectively reference those animation tree state machines.

i.e., this works: image

but if I try to nest that same configuration within a blend tree (here marked torso), I cannot get it to work: image

I tried naming the animation state chart node "torso/idle" etc., but /'s are not allowed. image

Edit: I just saw the error message. Without a workaround to this I can't figure out a pattern that wouldn't cause multiplicative states for separating leg and arm motions. Which means, despite the great functionality this offers, I can't use it.
image

derkork commented 5 months ago

Sorry, i totally overlooked this one. So the AnimationTreeState is really just a small wrapper around the animation tree and I'm rather inclined to remove it from the package altogether as its really tool simplistic and it's easily the one I got the most tickets about.

The animation tree state does nothing really fancy it just grabs the tree root at _ready and extracts the root state machine from it. Then when the state is entered it simply calls the travel function of the state machine with the state name. I think you're better off just making your own script that directly interfaces with your animation tree and calls the necessary methods. You can still call this custom script from the state chart nodes (using the the state_entered signal).

gaengberson commented 5 months ago

Thanks for the reply.

I would like to say that if should you decide to flesh this feature out and add support for nested animation trees it would help a lot.

One of the main things I am getting out of your addon is easily building in cooldown or lockout timers that can control things like iframes, recovery frames, and combo timers. Doing this natively is really difficult, and requires me to juggle courtines and timer nodes.

derkork commented 5 months ago

The thing is that there are a lot of ways to do animation control and any implementation I will choose will not work for someone. E.g. you can bury your animation tree state machine 3 levels deep in your animation tree. You could have more than one. You may decide to use a different animation tree per state. The AnimationTreeState / AnimationPlayerState nodes were some attempt at providing a "batteries included"-experience but I realize now that there are so many ways to do this, that either the tool falls flat (as the current implementation does) or its complexity will be the same as using the AnimationTree / AnimationPlayer directly in which case nothing was gained. If you have an idea of a workable approach I'm all ears as right now, I don't have one.