Skip to content

Can godot values be initialised inside of Go init() functions? #9

Answered by Splizard
ardawan asked this question in Q&A
Discussion options

You must be logged in to vote

Most gd package functionality is invalid before gdextension.Link is called, as this is what connects everything in the package up to Godot. You're probably calling this in main which is after init so gd functions won't work inside a init function. Even if you made sure to call gdextension.Link beforehand, not everything from Godot is initialised when Go starts up.

If possible, perform initialisation inside a Node's Ready implementation. There isn't a preload equivalant yet, I'll have a look at this, it will probably be based on struct tagging if added. At this stage. A gd.ResourceLoader can be added to your struct, it's a singleton so it will be instantiated for you and I believe it has a L…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ardawan
Comment options

@Splizard
Comment options

Answer selected by Splizard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants