Variable Name of Preload Packed Scene in two scripts

Godot Version

4.5.1

Question

I have two scenes, Area2D as root node, each has a script attached. One has the line

@export var projectile_scene: PackedScene = preload("res://creep_projectile.tscn")

the other one has

@export var projectile_scene: PackedScene = preload("res://player_projectile.tscn")

In the first one with the “creep_projectile” import, the command “projectile_scene.instantiate()” instantiates the player_projectile.tscn scene.

It seems the first scene overrides the variable name in the second scene. This would mean the two scripts share namespaces.

Can anyone explain this behaviour?

Thank you in advance.

How did you determine that?

I noticed both of your code snippets use @export.

As you may recall, @export allows you to modify the variable’s value directly in the Godot editor. So, please check if the scene has been accidentally modified there.

“Make sure to check the Inspector panel after selecting the relevant node in your scene to see if the exported variable values differ from what you set in code.”

Thank you for your reply.

@normalized the instance looks different, also i can see the nodes name in Remote tabs.

@yihrmc I can trigger this error just by adding or reoving a suffix to the variables name, no changes in the inspector needed.

Unfortunately, the problem solved itself. It stopped triggering when playing around with it. Hm… Maybe its me but there are some strange things going on.

Thank you anyway, i’ll try to provoke this error again.