How to get the url from an object inside another

Hi there everyone. I’m sorry to bring up this topic again, I know it has been discussed many times before, but I’ve read through a dozen related threads and still haven’t found a decent solution.

I always feel handicapped regarding Defold’s addressing system. For example, I can get the ID or URL from most objects, but I don’t know how to manipulate a URL and “extend” it to access an object inside another object. I feel like URLS and IDs are kind of untouchable, they work in their own way and there is no easy way to manipulate them (that I know of).

So, for starters, what should I do to get the URL of an object thats inside of an object, if I only know the URL of the parent object?

URLs doesn’t work that way. The URL of an object never changes. It is the same for a game object for its entire lifetime, from creation until it is deleted.

Parenting one game object to another only changes the scene graph hierarchy, it does not change the URL of the objects in the scene.

1 Like

Oh yeah, I remember discovering that the hard way, but in this case there’s no changing parenting.
Here child objects always remain with their parent, but those parent objects are created through a collection factory. I guess I could just store those parents’ IDs in a factory table and iterate through it each time, but I expected there would be an easier way.

I would want, in the same way you can get a component’s URL by adding a “fragment” to its parents URL, do the same thing but with a child object.

If they are created using a factory then the IDs are generated when they are created and you need to store them if you need them later.

Yeah, sorry, the URLs doesn’t work that way. There is a concept of relative URLs which probably is close to what you are asking.

Yeah I’ve read that article a few times, (another one yesterday). I can’t use relative URLs because I wanna control those objects from an external one, lets call it the input manager.
Can you suggest any other workarounds?

Can you share a minimal project that I can look at to better understand what you want to do?

Hey Britzl, sorry for replaying so late, I had already found a workaround. Usually my struggles with Defold are not that I can’t do something, its that the solutions I end up using seem a bit convoluted, and I just wonder if there’s a proper, simpler way that I don’t know about. But its okay, even if it could be improved, I don’t really need my code to be super efficient, sometimes I just get caught in that perfeccionist mindset. What I actually need is to let go of that, otherwise I’ll never finish any project haha.

1 Like