Godot Version
Godot Engine v4.6.2-stable
Question
Imagine I have these scenes: turret.tscn, projectile_turret.tscn, ray_turret.tscn.
projectile_turret.tscn and ray_turret.tscn inheirt turret.tscn. Yet, both of these scenes have their own special nodes for their own needs.
Now Imagine more scenes: example_projectile_turret.tscn which inherits projectile_turret.tscn. and example_ray_turret.tscn which inherits ray_turret.tscn.
The problem is when I try to .instantiate() the example_projectile_turret.tscn in-game it actually has nodes from ray_turret.tscn.
Which makes no sense because the Explorer of example_projectile_turret.tscn looks like this:
And the .tscn file when opened in text editor looks like this:
[gd_scene format=3 uid="uid://cs6fs5icr287d"]
[ext_resource type="PackedScene" uid="uid://bkkfw8fxxsff7" path="res://scripts/turrets/projectile_turret.tscn" id="1_iej6j"]
[ext_resource type="PackedScene" uid="uid://c511kx2fuxds7" path="res://scripts/turrets/bullet/resources/example_bullet.tscn" id="2_vdgmv"]
[ext_resource type="Resource" uid="uid://cu5w6rqx235h" path="res://scripts/turrets/upgrades/resources/example_projectile_turret_upgrade.tres" id="3_15rcu"]
[node name="turret" unique_id=505394040 instance=ExtResource("1_iej6j")]
projectile = ExtResource("2_vdgmv")
turret_id = "turret"
turret_name = "Turret"
upgrade_data = ExtResource("3_15rcu")
attack_range = 15.0
Meanwhile in-game it shows that it the actual added turret scene has nodes from ray_turret.tscn.
And to prove more that I indeed instantiate example_projectile_turret.tscn here’s my code:
extends TextureButton
@export var turret : PackedScene
# ... this script is part of UI which is in autoload CanvasLayer
func _button_up():
Gameplay.current_money -= price
var d = turret.instantiate()
d.position = get_parent().click_position
d.turret_price = price
get_parent().turrets.add_child(d)
Gameplay.close_buy_turret()
And the screenshot from inspector:
More weirdly… if I re-open my project then example_projectile_turret.tscn changes and inherits ray_turret.tscn when I do not need it to be like that.
Re-creating example_projectile_turret.tscn by right-mouse-clicking on the projectile_turret.tscn and creating a scene from it gives the same result.
WHAT THE HELL?


