Hi!
I’m trying to get an animation from a BlendSpace, so I can get the animation length. Currently I have a simple setup with a BlendSpace1D containing 3 animations. These blend using an integer from 1-3 (indicating a certain level of animation).
In pseudocode:
var level: int = 1
var animation_length: float = blend_space.get_animation(level).length
await get_tree().create_timer(animation.length).timeout
As stated in this reddit topic I’m currently grabbing the length directly from the AnimationPlayer, which is a decent workaround.
And learned there is a AnimationNodeAnimation class, which you use to programmatically assign animations to for example a AnimationNodeBlendSpace1D, and in there you can access the Animation. Maybe there is there a way to get an AnimationNodeAnimation from the BlendSpace1D?
I get access to the blendspace using graggu’s code:
var blendTree := self.animationTree.tree_root as AnimationNodeBlendTree
var blendSpace := blendTree.get_node("Block") as AnimationNodeBlendSpace1D
var blendTree := self.animationTree.tree_root as AnimationNodeBlendTree
var blendSpace := blendTree.get_node("Block") as AnimationNodeBlendSpace1D
var animationNode = blendSpace.get_blend_point_node(0)
if animationNode is AnimationNodeAnimation:
var animationName = animationNode.animation
var animation = animationTree.get_animation(animationName)
print(animation.length)
So it is only the name then. I think it’s a bit too much effort for my application, but at least I now know I can get it from the animation tree directly.
var animation_length = animation_tree.get_animation("character_animations/" + type + "_" + str(level)).length
await get_tree().create_timer(animation_length).timeout