# Change prototype in factory (SOLVED)

**URL:** <https://forum.defold.com/t/change-prototype-in-factory-solved/602>\
**Category:** Questions\
**Created:** [December 9, 2015, 2:09am UTC](https://forum.defold.com/t/change-prototype-in-factory-solved/602 "2015-12-09T02:09:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pikpiak](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/p/ee7513/32.png) [@pikpiak](https://forum.defold.com/u/pikpiak)\
**Post date:** [December 9, 2015, 2:09am UTC](https://forum.defold.com/t/change-prototype-in-factory-solved/602/1 "2015-12-09T02:09:08Z")

</div>

Hi, is it possible via scripts to change the prototype assigned to a factory for creation?

I’m trying to have a unitMob.factory spawn dynamically from a list of 20+ mob gameobjects, is this the correct way to go about it?  
Or do I need to setup a factory for each mob unit instead?

Sorry I’m still fairly new to both defold and lua here, please bear with me.

---

<div class="post-metadata">

**Author:** ![sicher](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sicher/32/8_2.png) [@sicher](https://forum.defold.com/u/sicher)\
**Post date:** [December 9, 2015, 7:39am UTC](https://forum.defold.com/t/change-prototype-in-factory-solved/602/2 "2015-12-09T07:39:34Z")

</div>

No, the prototype is static. You can either set up a factory for each type or spawn a gameobject or the content of a collection (collectionfactory) and control the initial state through init properties provided through factory.create().

---

<div class="post-metadata">

**Author:** ![pikpiak](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/p/ee7513/32.png) [@pikpiak](https://forum.defold.com/u/pikpiak)\
**Post date:** [December 9, 2015, 1:09pm UTC](https://forum.defold.com/t/change-prototype-in-factory-solved/602/3 "2015-12-09T13:09:06Z")

</div>

Cool, guess I’ll have to work around this then.  
Thanks for the clarification 😃

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [April 8, 2024, 7:05am UTC](https://forum.defold.com/t/change-prototype-in-factory-solved/602/4 "2024-04-08T07:05:57Z")

</div>

It is possible now since Defold [1.4.3](https://forum.defold.com/t/defold-1-4-3-has-been-released/72745)

Manual:

> **[Dynamic prototype - Factory component manual](https://defold.com/manuals/factory/#dynamic-prototype)**
>
> Factory components are used to dynamically spawn game objects from a pool of objects into a running game. | This manual explains how to use factory components to dynamically spawn game objects at runtime.

Example:

> **[Dynamic factories](https://defold.com/examples/factory/dynamic/)**
>
> This example shows how to change the prototype game object used by a factory component.
