Skip to content

GDScript initialization order for scene instances clarifications #11154

@ketexon

Description

@ketexon

Your Godot version:

v4.5.beta.custom_build [2d113cc22]

Issue description:

In the GDScript docs for initialization order, it briefly mentions that exported variables are applied after _init for instantiated scenes.

However, it is not clear that this also applies to the script field itself. This causes the original script's _init to be called first, then the new script to be applied, then its _init being called, which appears like a bug.

In addition, this means you should be very cautious using exported variables in _init, since if that script is ever used in an instantiated scene, the values will not reflect the overridden values.

URL to the documentation page (if already existing):

https://docs.godotengine.org/en/4.4/tutorials/scripting/gdscript/gdscript_basics.html#initialization-order

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:manualIssues and PRs related to the Manual/Tutorials section of the documentationtopic:gdscript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions