# How to set dynamic factory prototype?

**URL:** <https://forum.defold.com/t/how-to-set-dynamic-factory-prototype/79088>\
**Category:** Questions\
**Created:** [December 7, 2024, 8:58pm UTC](https://forum.defold.com/t/how-to-set-dynamic-factory-prototype/79088 "2024-12-07T20:58:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![EP2003](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ep2003/32/38071_2.png) [@EP2003](https://forum.defold.com/u/EP2003)\
**Post date:** [December 7, 2024, 8:58pm UTC](https://forum.defold.com/t/how-to-set-dynamic-factory-prototype/79088/1 "2024-12-07T20:58:56Z")

</div>

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:

```lua
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.

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [December 8, 2024, 5:38am UTC](https://forum.defold.com/t/how-to-set-dynamic-factory-prototype/79088/2 "2024-12-08T05:38:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [December 8, 2024, 8:40am UTC](https://forum.defold.com/t/how-to-set-dynamic-factory-prototype/79088/3 "2024-12-08T08:40:09Z")

</div>

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

> [@EP2003](#):
>
> `/Circuit Chase/wire_manager/level_carver.goc`

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.

---

<div class="post-metadata">

**Author:** ![ainonovo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ainonovo/32/27068_2.png) [@ainonovo](https://forum.defold.com/u/ainonovo)\
**Post date:** [December 9, 2024, 7:06am UTC](https://forum.defold.com/t/how-to-set-dynamic-factory-prototype/79088/4 "2024-12-09T07:06:22Z")

</div>

```
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

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [December 9, 2024, 9:23am UTC](https://forum.defold.com/t/how-to-set-dynamic-factory-prototype/79088/5 "2024-12-09T09:23:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ainonovo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ainonovo/32/27068_2.png) [@ainonovo](https://forum.defold.com/u/ainonovo)\
**Post date:** [December 9, 2024, 10:04am UTC](https://forum.defold.com/t/how-to-set-dynamic-factory-prototype/79088/6 "2024-12-09T10:04:12Z")

</div>

yes, collection must be loaded with this go

---

<div class="post-metadata">

**Author:** ![EP2003](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ep2003/32/38071_2.png) [@EP2003](https://forum.defold.com/u/EP2003)\
**Post date:** [December 10, 2024, 9:36am UTC](https://forum.defold.com/t/how-to-set-dynamic-factory-prototype/79088/7 "2024-12-10T09:36:46Z")

</div>

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.
