Is there a way to get a export variable value.

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

I made an enemy scene with an enemy script. My plan is to export some variables like Speed, Damage etc, so I could set different values in the inspector. I want to load different random sprites so the enemies will look different. The idea is to export a variable enemy type, for example if the type = 1, load a certain array of sprites into the animation player randomly. This way, I could only use 1 scene for many different type of enemy. But I am not sure if there is a way to get the value which has been set in the inspector. Thank you.

:bust_in_silhouette: Reply From: DDoop

You should be able to access an exported variable from another node just like any other non-exported member variable: Owner_Node.desired_variable where Owner_Node is a reference to the node that owns the variable (usually via get_node()/$ or get_parent() for nodes that already exist in the scene tree) and desired_variable is the exact name of the desired variable.

Got it work, turn out that I was over thinking about the export variables, they behave just like other variables, thank you.

Idleman | 2020-07-31 03:36