0 votes

I have a character with multiple weapons all of them having their own animations and put them all inside a AnimationTree Node, instead of going trough the hassle of making a giant and confusing animationtree, without talking about the scripting nightmare it was going to be since it's mostly the same animation cycles (walk, idle, attack,etc) repeating with only the animations for each weapons changing.
I decided instead to put each weapon animation in its own nested state machine like this:

Each state machine has basically the same animation states (with the animations being different of course):

Now all I want to do is being able to switch between nested state machines depedent of what weapon my character is using. Every help is much appreciated!

Godot version 3.2.3
in Engine by (254 points)

1 Answer

0 votes
Best answer

Okay, I've figured it on my own, it's pretty long to explain for my end but here's at least how you switch from the root state machine to a sub-state machine (it's on C# but it shouldn't be that hard to convert it to GDScript).

playback = (AnimationNodeStateMachinePlayback) GetNode<AnimationTree>("AnimationTree").Get("parameters/playback");
    playback = (AnimationNodeStateMachinePlayback) GetNode<AnimationTree>("AnimationTree").Get("parameters/sub_machine_state/playback");

However I don't know if I'm going to keep it like that, there's plenty of FSM plugins in the Assetlib that probably do the work without the hassle.

by (254 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.