I am creating collections from factory.
In collection:
root_game_object
root_game_object\go1 #script
How to create url to “\go1” in function init(self) of new collection ?
That do not work:
Urls are not dependent on game object nesting. So, in your case, “root_game_object” and “go1” would be siblings, so you can do msg.url(“go1”) from root_game_object’s init().
If you work with collection factories, remember that collectionfactory.create returns you a table of all the created game objects. With that you can do created_gos[hash(“root_game_object”)] to get the url of the root and created_gos[hash(“go1”)] to get the url to go1.
If you want to receive path to internal go of spawned collection in init(), you have to use go.get_id() with relative path to your object, in your case go.get_id(“go1”)
docs: https://www.defold.com/ref/go/#go.get_id:-path-