I'm making a tower defence game where different towers shoots different projectiles. Each projectile has a range variable and I want to make sure that the turrets that shoot each projectile has the same range value.
Right now, I have turrets storing a PackedScene of the projectile they'll shoot. E.g.: "fireball tower" will have myProjectile
pointing to a scene called "fireball"
To make sure that the tower has the same range as its projectile, I'm trying to do something like this:
func _ready():
range = myProjectile.range
but this obviously does not work because Godot won't let me read variables from an uninstanced scene (PackedScene).
One possible way to work-around to this (that I don't love) would be instancing a projectile at _ready(), getting its range and then freeing the projectile. but this has the downside of triggering the events of the projectile's creation and destruction (playing sound/exploding) whenever the tower is built, and might interfere with future features that detect projectile creation/destruction
So, I was hoping that someone has a better idea of how to get a user-set variable like "range" from the PackedScene directly without having to instance it.