0 votes

I want to inherit a scene but not the script, to try some polymorphic functions in a inherited script.
Godot doesn't want to load an inherited script in the inherited scene.
A completely new script works, but it need to maintain the two scripts. The two scenes shares lot of stuffs.
If is it possible how to do this please ?

in Engine by (516 points)
edited by

2 Answers

+1 vote

You could see what is the script loaded with get_script and then, use set_script at ready(or at process) of the parent node to load another one at runtime...

On the parent node, call the set_script on the child scene with any kind of method you want:

if Input.is_action_pressed("ui_down"):
    get_node("my_awesome_scene").set_script("res://my_other_awesome_script")
by (233 points)
edited by

Shouldn't you use set_script(preload("..."))?

Yup, missed that one, thanks.

0 votes

Now it works. Don't know what I did to make it work. Sorry

But now I'll try to find how to extends the functions too ...

Thanks for the help brunosxs.

by (516 points)
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.