Animation Tree State Machine properties are null every other process frame

Godot Version

4.3 stable

Question

Whenever I try to read and or set certain properties of my animation tree state machine, they return null or don’t work because I tried setting a property of a null object.

image

In this line I am trying to see the blend position of a blend space I set up in an animation tree. This animation tree is an exported variable set in the editor. This line is inside the process function.

When I run the project, the output looks like this.

image

Every other frame the output is null, and it happens with many properties. This is a major problem because setting properties in ready doesn’t work because everything is null.

I haven’t seen this documented anywhere else, any help is appreciated.

I could not reproduce your issue using Godot 4.3

Post more information like your AnimationTree nodes and configuration for example.

I found that the issue seems to be with the fact that the script this is running in is a class_name script, in this case called Actor. It should also be noted that “anim_tree” is an exported variable in which I assign an Animation Tree.

image

When I run this code in another script attached to an actor node, this issue does not happen, though I do not understand why.

I assume that process is not meant to run twice like this, as putting a process function in player.gd seems to take priority over the process in the actor_class script.

Just realized I didn’t actually reply to you, haha. Please look at my post above.

It does not matter how many times you try to get the value in a frame, it should not fail.

The only way I can see that failing is that a node/scene was probably assigned an AnimationTree which does not have that parameter. Like, if you have 2 scenes that use the same script Actor but each one has assigned different AnimationTrees

I only have one Actor currently, and the problem has now progressed to the whole animation tree being null upon running the main scene. I feel it has to do with the fact that the animation tree is an exported variable.

Once again I didn’t reply, sorry.

Did you set the exported AnimationTree node in the scene? I can’t reproduce your issue otherwise.

Yes,


I’m now getting an error where the animation tree is null entirely on runtime. The state machine can’t be loaded because you can’t use get() on a null value.

Turns out I did have another actor sitting somewhere in my main scene, they did not have their animation tree assigned.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.