Hey, I'm quite new to godot and was wondering if the way I'm currently instancing my things is reasonable.
export var equipWeaponPath = "res://foobar"
var weapon setget _set_weapon
func _ready():
var weaponInstance = load(equipWeapon).instance()
_set_weapon(weaponInstance)
func _set_weapon(arg):
if weapon:
weapon.queue_free()
add_child(arg)
weapon = arg
So the reason why I'm doing this is so I can change weapons during runtime, just by doing something like...
func _this_runs_every_frame():
if condition:
_set_weapon(new_weapon)
...and easily change my weapon.
This seems to me like a pretty convoluted way to do something seemingly simple. Am I overthinking? What other ways are there to do this, if any?