Armory prefabs discussion

In Blender there is no way to have a good prefab system, Blender does not allow two objects with the same child objects name.

A work around in logic nodes or code is to check the first letters of a child object name (String.startsWith() ), but that’s not great.

There is at least two main features for prefabs :

  • Visible as one object :
    Prefabs in Blender hierarchy would be represented as a simple object whose content would not be visible, unless you open original prefab file and edit it.
  • 3D prefab displayed with an thumbnail in Armory resource explorer when it will have one.

Should Armory make it’s own prefab system better suited for games instead of trying to use Blender work around ?

I don’t know that it makes sense for Armory to have a resource viewer because it has to use Blender to identify and export resources. If Blender had this feature that would be another story, but it depends on being implement that in Blender itself.

I think that Armory should work with Blender and like Blender. If linked proxy objects are not working in Armory, then that is probably just something that needs to be fixed in Armory. Linked proxies work how you are imagining in all other respects right? Where is the failure point for them?

1 Like

There are add ons out there that actually can do this. In the new kitops add on you create an asset in it’s own blend file complete with children and even animation and the add on shows those pieces in thumbnails. When you insert it into your file it brings in all the parts and even has a predetermined method for Boolean operations on the specific mesh you are working on.

So if we could get a system that you create “prefabs” in a blend file and then in the master file be able to add them,. either in normal append like fashion or dynamically though code or nodes, it would solve a ton of issues. I think the 2 main ones are

  1. the prefab needs to bring in the parent object, all of its children and all of it code (node or haxe)
  2. multiple prefabs with the same name (at least as far as the code is concerned) need to be able to used mostly at run time.

for #2 would a tag like system fix this - where you are looking for a certain property of the object instead of the object itself. multiple objects can have the same property name (say destructible) set to a Boolean at the same time. So you would search from that property on all the objects in consideration instead of the name. therefore the name itself doesn’t matter much.

You might be able to do that with Blender groups. All that would be required, if it isn’t already implemented, would be adding the list of groups that an object is in to the Armory export. That would satisfy any type of “tagging” requirements I think.

If there are addons for this then we should be able to learn from them and how they do it or just integrate Armory with them. That would be great to satisfy a little bit more of the “Game Engine like” UI. :+1:

1 Like

Here are a couple of examples to look for ideas:


http://www.chocofur.com/chocofur-model-manager-for-blender-free-1-0-0.html

Some of these are paid but I wonder if someone capable of working with this kind of code could ask for some help from these developers and pull off something amazing.

I already tested proxy, they don’t work
1 ) you can only Link or Unlink one child object
2) Blender hierarchy see proxy content, so again Blender won’t accept proxy or prefabs with child object having the same name.

Groups have other use i think, i don’t know if it can used as tags with a name.

yes

Not necessary. In Unreal 4 or Unity, each prefab you drop on the 3D scene is a new instance of the prefab, in the hierarchy these prefabs copy can’t have the same name.
Because each object root node on the hierarchy has a unique name.

Armory need one like those resource explorer :sweat_smile:

About prefab Armory is stuck until it gets it’s own solution.

1 Like

OK, :thinking: if linked proxies don’t work, have you tried group instances? They don’t have visible children and you might be able to link the group from another blend and create a unique instance of that group in the blend that you are importing it to.

Nothing in blender is going to grab nodes or Haxe from other projects without some customization. :thinking: The closest thing that exists that does that, that I know of, is the modding setup I was working on, but that isn’t quite right in this instance because you have to compile mods separate from the game, and the point is that we want to be able include the contents of the other blend and compile it once in the blend that we are including it into.

This is a pretty difficult one to solve with the differences between the Blender and the “Game Engine” approach. I’m going to do some experimenting for a structure for a moddable game ( just because that is what I’m working on ) and I might find out a little bit of how we might be able to manage imports and other blends. There might be a different way that we are not thinking of that is different that the typical way to do it, but that can still satisfy our needs.

1 Like

When you append an object from another scene it pulls the material node in. Shouldn’t we be able to pull in at least the nodes. Right now when I append a item with a node tree on it, it shows up as having the trait it just doesn’t pull the actual nodetree with it and you have to reattached it. But it seems like it is within blenders structure to do so.

Oh, that is a good point about the Material nodes. I didn’t think about that. We might be able to look at how it does that.

1 Like

Same problem, duplicate a group it’s child objects can’t have the same name as the other group child objects.
It’s the way Blender works.

Until we can make some object with hidden content in Blender hierarchy (child objects, traits, particles, animations, materials , sounds) ,prefabs won’t be possible.

I think Lubos is the most appropriate person to know if some solution could be possible or not.

As discussed before, proxy and groups does not work for prefabs.

Will Blender 2.8 allow child objects with same name and some sort of prefab ?

Otherwise most game dev possible in other 3D engines won’t be possible in Armory.
For example duplicate characters with child object named “mount pivot”, this child object retrieved used in code or logic nodes.

If nothing else works, something that does work is to separate any objects that need to be duplicated into different scenes and spawn those scenes at runtime. That is how I am handling my player at the moment. The player is in a scene all by itself and is spawned by a spawn point object ( an empty ) that just uses a Spawn Scene node triggered On Init.

Hierarchy does not allow two objects with the same name, whatever they are in the hierarchy. (I already tried scenes)
I’m the only one requesting prefabs, i understand it’s too early, but i test Armory as i would be making a real game.

Only solution will be to make a request for Blender 2.8.

Yes, you can’t name two objects the same thing, but in a lot of circumstances you should be able to get away with that. If you have two different kinds of enemies, even if they are in different scenes, you will not be able to name both of their guns “Gun”, but you could name them “SoldierGun” and “BossGun”. Or you could leave the names “Gun.000” and “Gun.001” and use the Get Child node and get the child that starts with “Gun” in your logic nodes. That is one approach.

When it comes to having multiple instances of enemies or other objects and you don’t want to do the whole “starts with” thing, Armory has absolutely no problem if you spawn any number of instances of a scene regardless of the fact that you end up with multiple objects with the same name in the scene. If you take your “Soldier” scene, you can spawn any number of soldiers using spawn points or anything else, and those soldiers will function just fine if they are using logic like Get Child instead of Get Object to make sure that they are selecting the objects out of their own hierarchy.

I just tested this with my own game. I can spawn two player scenes, each containing objects like CameraPivot and Gun, and in my logic nodes I can do this in a scene where I spawn two of my players and both of them work just fine:

They both fire their guns when I click the mouse. Does that make sense?

I’m very interested, could you upload the whole example ?
I think my scenes setup was different.

What does using scenes implies ? Does it has some cost on Armory ? Instead of using objects and child objects ?

Using scenes actually does represent the overhead of parsing the scene file when it is first loaded, but now that I think about it, there isn’t any reason you shouldn’t be able to just use an object in the scene you are already using and spawn an instance of the object ( or just preload the scene; there is a way to do that in Haxe ).

My particular example is dependent on some non-merged changes, but I should be able to make a quick example for you.

1 Like

We should ask Lubos about overhead about scenes usage impact on Armory.

I’ve been around the code quite a bit and I’ve seen that it parses the scene when you request loading it and it caches the scene in memory after the first load. Any subsequent attempts to load the scene retrieve the scene from memory.

That is what I’ve seen, but there could still be more to it.

1 Like

Here is an example:

SceneSpawn.blend (560.6 KB)

It just has a “Player” scene that is a ball with a hammer and node logic to swing the hammer when you press spacebar. The “Game” scene has to spawn points “PlayerSpawn.000” and “PlayerSpawn.001” that each just spawn the “Player” scene in their current location on Init. On update, both players will get their own “Hammer” child object and set it’s rotation based on whether or not you are pressing the spacebar.

Lubos actually did mention something about Blender collections maybe being able to help us not need to parse scenes for spawning objects:

1 Like

That’s two ways or work around

  • using “get the child that starts with”
  • using code or logic node to spawn scenes

I hope there will be something to not need to spawn or use “name start with”, but a real prefab system like Unity for example.
You create the prefab and can directly drag and drop and duplicate on the scene, child objects can keep the same name.