Is it possible to get the url of a component that's part of collection spawned by factory from within the spawning object? (SOLVED)

Sorry if the title’s a bit clunky, not sure how else to phrase this question.

The issue I’m running into is: when I spawn a collection (enemy) via a collection factory in my level controller I can access each nested game object’s url by indexing the table with the hash of that go’s id, but when I print out the whole table returned by collectionfactory.create, there’s no entries for any of the components, just the go’s.

No matter how I try and manipulate the urls I can get, I can’t seem to get a path to one of the components. For reference, I have a collection for the enemy, with a main root object containing its controller script. The relative url of the script is /doppelganger#enemy, and I can access the url of this root object by indexing the table I get from creating this collection with [hash("/doppelganger")]. Once I have the url to the object, I can’t just append the component id to it, because it’s already a hash.

All in all, I can work around this with some callbacks, just thought it was kind of a strange limitation and wanted to make sure I wasn’t missing some obvious solution… For reference, the reason I need access to the script and not just the go is because you can only access go properties declared in a script by addressing the script directly, not the object it’s attached to, which might be its own issue (or there might be a very good reason it has to work like that).

Thanks in advance if anyone has time to help with this, and thanks for all the help I’ve gleaned from just lurking these forums for a while.

This question answered here: Get Address of Component From Collection Factory Instance (SOLVED)

Simply use msg.url(collection, hash(id), component).

7 Likes

Oh sorry, I must’ve missed that when trying to google the topic. That did the trick, thank you! I’ll mark this as solved.

1 Like