BlendTrees and StateMachines

Godot Version

4.2.2.stable.mono

Question

Hey guys, I’ve got a question about BlendTrees and StateMachines. I had a StateMachine controlling my walk animations, I had a BlendSpace2D blend between the different walking animations and idle. I also had attack and other animations coming from and going to the BlendSpace2D. However I want to control the speed of the attack animations based on player stats. It seems the way to do that is with a BlendTree as the root of the AnimationTree and then adding a time scale. I’m not sure how to handle this though. Should I ditch the StateMachine completely and just use a BlendSpace2D? I tried to create a StateMachine within the BlendTree but it doesn’t play when connected to output. I’m not sure why the StateMachine(which contains the aforementioned BlendSpace2D) doesn’t play when connected to the output of the BlendTree. Is there a good way to add the StateMachine I was using into the BlendTree Any help or suggestions that anyone can give would be greatly appreciated. Thanks

I was connecting my states to end with out a condition, so that’s why it wasn’t playing as for controlling the speed of attacks I am still working on that

https://youtu.be/n872lbC-_BU?si=p90SWMAQeL3-PpLP ← This is a really good video going over BlendTrees and StateMachines

I solved this by creating a BlendTree inside of my StateMachine. Then going into the BlendTree add an animation, connect that animation to a TimeScale and the TimeScale to the output. Then in your code you can access the scale with something like parameters/StateMachine/Animation/TimeScale/scale and pass it the scale you want it to have. I actually ended up making the root of the entire AnimationTree a BlendTree for more flexibility. Anyway I hope that helps somebody, if you want anymore info feel free to reach out, and if you want a good concise explanation of the animation system that video is really good.