0 votes

I'm looking for a way to have a script that is never added to the scene_tree itself (and as such never has ._ready() called) call some kind of initialization function whenever it's instanced.

This is just to save me some/a lot of typing if I instance it often, I know I could just run something like an Instance.start() on it every time after instancing it from the other script.
Especially since this makes it so I can't just onready the instance this way.

in Engine by (25 points)

1 Answer

+3 votes
Best answer

I just woke but still I'm pretty sure all classes get called _init() when created an instance with my_class.new(). Can even have arguments added.

by (86 points)
selected by

Thanks, works just as expected!
Nice to know passing arguments works too, that's a neat added bonus there.

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.