Modify export variables from extended script?

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

Hey there, so I’ve basically got a scene structure like this: I have a scene called PartyMember which is basically a kinematic body/animated sprite combo. I’d like to have an exported variable of type PartyMember in this scene so that inherited scenes can use it. However, when I create a scene that inherits PartyMember, the option to change the value is missing. Is this a shortcoming of Godot or am I missing something? Thanks.

:bust_in_silhouette: Reply From: Sween123

Use “export var
Example: export (String) var MemberType
If your scene inherit the script that contains export (String) var MemberType, then yes this scene will have the option to change the value of this property inside the Inspector, too. (Just put the scene as a child node is not the same as extends its parent class, a script is also a class that extends the class of a node)
If you want a scene to be reused, save this scene. Later you can just load it and instance it, the options you exported will also be there.

:bust_in_silhouette: Reply From: Sethington

It ended up working when I added the line

class_name PartyMember

to the script, now children have the export variables.

Thanks, this worked for me too.

Not sure why the script that extends the other class also has to have a class_name set in order for exported vars to be shown correctly in the interface, but adding a class_name fixed the issue.

unconcernedcitizen | 2022-01-14 00:44