Lack of information about using dynamic prototype setting for collection factory

I’m trying to generate level consisted of different rooms. Rooms are just collection of different object and enemies in it. I tried to use collection factory to generate new rooms on the fly. But when I want to change prototype of collection factory from script using collectionfactory.set_prototype() function, I receive this error “Failed to load collection factory prototype /game/levels/room_001.collectionc”. Tried to follow example listed in Collection factory manual, but looks like it not working. On other hand changing prototype for OBJECT FACRORY work fine. What I want it’s create pool with different rooms named like room_001, room_002 etc. and pick random one and spawn.
My project structure
Screenshot_5
Collection factory properties
image
Outline of main collection
image
Error


Factory script
image

I do something similar but I use multiple collection factories. Randomize which one gets called.

1 Like

The documentation for collectionfactory.set_prototype(url, prototype) expects prototype to be a project path. In your case it looks like it should be /game/levels/level_2.collection.

I tried that too and its not helped, because for some reason when building the project all other collection not build into collectionc, only one collection defined in collection factory does.

Please, take a look at this old post about the Dynamic Prototype feature to make sure you use it in the way it was initially designed:

Our build system builds only linked resources. If you never link the resource anywhere, it will not be built. A ‘linked resource’ in this case means being specified in a factory or in some other place specific to that resource. It’s not enough to be in the project folder.

If you want to have a few levels in your game, just create a few collection proxies (or collection factories).

4 Likes