OneShot Autorestart Delay

Godot Version

Godot 4.2.2


I’m writing a game in C#. I added a OneShot node in AnimationBlendTree that will trigger a Punch, simple. How can I access the autorestart_delay and set it from the code?

I believe from the animation tree you’ll want to copy the property path. Then use the .set function on said tree. Make sure you’ve selected the animation tree, at the top of the inspector yours says “AnimationNodeOneShot” but it will be easier to copy from the AnimationTree node.

I’ve posted a screenshot of me selecting the AnimationTree, copying it’s blend parameter from the inspector, then using it in a script (highlighted in red)

This is the highlighted line if you have trouble reading it.

animation_tree.set("parameters/Walking/WalkDirection/blend_position", Vector2.ZERO)
1 Like

Thanks for the reply! That’s what I thought too, that it’s a value assigned by AnimationTree.Set(). But just like in AnimationTree where you have access to …parameters/OneShot/request and that’s how you trigger animations, with set_autorestart_delay, it’s not the same. I have no idea how I can set this value from C# code.

animationTree.Set("parameters/Punch/request", (int)AnimationNodeOneShot.OneShotRequest.Fire);

Ah I see. Try exploring into tree_root as AnimationNodeBlendTree. Here’s how I think a gd script would look, as gives type information, in C# I suppose you will need to downcast.

var blend_tree := animation_tree.tree_root as AnimationNodeBlendTree
var punch_shot := blend_tree.get_node("Punch") as AnimationNodeOneShot
punch_shot.autorestart_delay = my_value
1 Like

Great :grinning:! That’s what I was aiming for. I’m attaching the C# version below. Thanks a lot for your help!

AnimationNodeBlendTree blendTree = animationTree.TreeRoot as AnimationNodeBlendTree;
AnimationNodeOneShot punchShot = blendTree.GetNode("Punch") as AnimationNodeOneShot;
punchShot.AutorestartDelay = _autorestartDelay;
1 Like