Hello!
Whenever I instance something in script, I preload the scene file location, and instance from that.
For example:
var objectToInstance = preload("res://instanceScene.tscn")
func instancingFunction():
var newInstance = objectToInstance.instance()
# Do anything I need to with the newInstance properties
get_parent().add_child(newInstance)
What I'm wondering: is it possible to instance from the current class instead? Something like self
but that can use the instance()
function? Basically, I want to be able to have an object clone itself (or tell other object how to clone it) without an absolute reference to the .tscn file.