How to set dynamic factory prototype?

So I understand .goc files are supposed to be .go files that are compiled, but when referenced as .goc files in code, they’re still .go files when uncompiled right? I don’t have to make the game object some special file or put it in some sort of collection or whatever?

I tried setting the prototype of a factory in code, referencing a .go file with the .goc extension, but it gives me an error saying:

ERROR:GAMESYS: Failed to get factory prototype resource: /Circuit Chase/wire_manager/level_carver.goc
ERROR:GAMEOBJECT: No prototype to spawn from.

level_carver is a .go file stored in a separate folder from the object this script is attached to.

You need to have this file in bundle. If you don’t have reference to go file this file not will be added in bundle.

To work with dynamic prototype you can use liveupdate.

Put all that object in collection. Exclude collection.

After game start. Load liveupdate. Then change prototype of your go to new go.

1 Like

This is a really advanced feature, aimed at developer that use Live Update without knowing all the content upfront.

It is possible that the file is called something different when it’s built.

Also, if you are not referencing the .go file anywhere, it won’t be built either, so that might also be the case.
Try setting is as a go.property, and make sure the file ends up in the build folder.

local url_ = 'robot#detail_factory'
factory.set_prototype(url_, '/robot/detail/body/' .. body_id .. '.goc')
local body_clone = factory.create(url_)

maybe this?

and dont forget add you GO to colection used in factory

This still doesn’t guarantee that the asset is built. You need to make sure to build it before you can load it.

yes, collection must be loaded with this go

After doing a bit more research I tried storing the dynamic prototypes in a collection and referencing them via a proxy in the spawning object and that worked.