0 votes

Hi everyone !
After tons of googling and documentation reading, I still can't figure out how to do one thing :

If I have a settings script/class that looks like this :

#settings.gd
extends Node
export var size : float
export var color : Color

And I use it in some other script (attached to a Planet node) that looks like this :

#planet.gd
const Settings= preload("res://Scripts/settings.gd")
var settings : Settings

How can I export the settings variable so I can access the size and color variables from the Planet node ?

Thanks in advance !

edit : the Planet node is just an empty node containing mesh instances and things like that

in Engine by (83 points)

Do I understand you correctly; you want to read constants from settings.gd into planet.gd and then export these as variables from planet.gd so you can edit them through the Planet node in the editor?

Yes exactly, that's what I want to do

1 Answer

0 votes
Best answer

I solved it myself ! I was adding an _init() function to my resource script and that was messing things up. I can now just export(Resource) var settings : Resource and access my data from there (I couldn't before because of the _init() function for some reason)

by (83 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.