How to have an animation as a attribute of a node?

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

I know that you can use the @export var to have custum attributes in a scene, such as an enemy having health, damage, and speed that can be changed in the editor. I want to have a building scene that will emit signals when the player gets close to it, and the building also plays an animation when the player is in range. But each building will be different, so I want to be able to instantiate that scene in the editor and change the animation.
I don’t want to just have a new scene for every type of building that exists. The root node is a staticbody2D, so when I place the building, I can’t change the sprite. How do I do this?

:bust_in_silhouette: Reply From: Inces

You can cast chosen types onto exported variables, by typing a class or type in parentheses after export keyword :

export ( Animation) var building_destroy