Is it possible to use properties from custom nodes as animation keys in the editor?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lvknd

I’d like to run an animation that interpolates between values of a custom property in a class that I extended from Node2D. Is this possible in Godot 3.5 or possibly 4.0? Is it possible to do this entirely in the editor or would it require code?

Since the answer is yes (export the variable) I want to add a tip: combine this approach with setget and you can animate just about anything.

e.g. This worm-like effect can be re-factored as an animation and configured in the Editor. NOTE: one caveat I haven’t figured out how to play the animation in the Editor yet but I imagine that could be done with tool. Please add a solution for that if you have one.

:bust_in_silhouette: Reply From: spaceyjase

Yes, you can animate custom properties (I assume you mean exports). Here, a single integer in an extended node:

enter image description here

If you find something can’t be animated, method calls are always possible too, which could run custom logic called by a ‘Call Method’ animation track.

:bust_in_silhouette: Reply From: jgee_23_

Yes, definitely. If you want to do this via the editor, simply export the variable you want to change, and you will be able to use the var as a key in an AnimationPlayer. You can export a variable like so:

@export var my_var

int my_var;

If you want to do this via code its a bit harder. You wouldn’t need to export the var, but you would have to create the animation via code which is long, tedious and annoying. The last alternative is to use tweens, they are very useful for making animations on the fly via code, I recommend using these instead of an AnimationPlayer to use by code.