Hello everyone! I try load prototype for factory with dynamic prototype. But GameSys have an error! Please tell my why? and best way to load dynamic prototype for factory
The error means that the new prototype doesn’t exist in the game archive. Defold will only include objects referenced from the bootstrap collection and it’s sub collections.
The main use case for dynamic prototypes is when combined with the Live Update feature when using a prototype from the live update archive. Are you using live update?
oh! I don’t use live update setting. I was checked live update and see it may be update by server. But it is not target I focus for project. I only want one factory in project can load to other prototype and don’t need to use many factory in project. Is there any way to do it?
No, you will have to create multiple factories.
Okay, thanks sir. I just try to find some way to perfoment my project. Hope in next future Defold will support that feature
So what is the problem with having more than one factory? How many different prototypes do you need to spawn?
I think have 1000 bullet type for my gun. I will must create 1000 factory for 1000 bullet type. So, if can load other bullet for factory, just create 1 factory and change 1000 bullet type
1000 bullet types?
What differs between these types?
Yeah sir! May be they have some attributes example: number of particles, box collisions… so hard to set parent by outside game object and just design to use, no script references
To be honest, I don’t see the difference between having a list of GOs names on disk you will have to manage to be able to set an object into a factory and a list of addresses to factories.
The only issue I see: it’s not that easy to create many factories for many objects at the same time (something like drag and drop with Ctrl
pressed, to create a factory for each dragged object with the same name the object has)
@AGulev Exactly sir ! If we can load another prototype into some folder, we don’t need to recreate the factory for the same job of other game object and save many time to do something else
I would make this data driven and have one bullet game object/prototype and one factory. And when I need the bullet to look in a certain way I use sprite.play_flipbook()
to change the visuals of the sprite in the object I spawn. If I need the size to change then I’d change the scale of the object. If I need the collision group to change I’d change that at runtime using physics.set_group()
. And so on.
@britzl Yes, of cause. But if factory just load and create an other game object were designed to done. We take that job so easy and quickly, no need many code
Ok, if you really want 1000 game object prototypes and 1 factory then one other option you have is to add these 1000 game objects to some collection in your game and reference but never load it using a collection factory. That way you are guaranteed to have all 1000 prototypes in your project and you can use factory.set_prototype()
.
Really! Ok thanks sir. I will try to do that way. May be that way is good answer for my question. Thanks so much!
Oh that work @britzl ! Thanks so much. Now I can use one factory for all spawn task of project