You need to use a loop.
What you are doing is calling the same method x number of times, x being the number of frames. But in your method, although you do instantiate 4 objects you are only affecting your geometry to one of them. As far as I know the objects created in the object instancer node are put in a pool to be reused when needed, they are not destroyed and recreated every time. That would make sense in order to increase performance.
To the point.
- Create a "Loop" with Add > Subprograms > Loop
- Add a "Parameter" of type "Object List"
- Create an invoke node on this loop with Add > Subprograms > "My Loop" (you can rename it)
- Set the iterations to 4
- Add a "Collection info" node, set it to your wall blueprints collections and plug the "objects" into your loop invoke input "Object List" input (you can rename it).
- Use a "Get Random List Element" Node and set it to "Single", plug the frame info added to the index into the seed, that way every wall will be randomised, and every frame the setup will change. Add a big number to the frame so that the two seeds are independant.
- Add an object instancer and set it to mesh, instances to 4.
- Add a new parameter of type "Object List", rename it "Mesh objects". Plug the instancer into the input of the invoke node.
- In the loop, Plug the wall blueprints into the "Get Random List Element" node.
- Add a "Get List Element" node and plug the mesh objects into it, and the index of the loop into its index.
- Add a "Mesh Object Output" node, plug both "Element" outputs into it (the random one into the mesh input). Ths swill automatically create a "Mesh object output" node, you can check "Use modifiers" if your walls have some. Click the button on the right of the "Mesh" line
- Now to translate the meshes to the origin : Get the opposite of the blueprint position, and translate the mesh using a compose matrix.
- Finally plug the index into a math node to multiply by 90, into a combine euler set to degrees and into an "Object Transforms Output" set to rotate around Z.
The final node tree:
Bonus :
If you want to get ALL possible combinations. We have to use a little script and mathematics.
Go to the scripting workspace, add a script, name it as you wish. Write this :
import bpy
import itertools
combinations = [range(len(blueprints.objects))]*4
linear_combinations = []
for combination in itertools.product(*combinations):
linear_combinations.extend(combination)
The result will be a very long list of integers, corresponding to each different possible combination. For 4 wall and 4 differents walls, I got 4*4*4*4*4 = 1024 different combinations. The integer being the index of the child object in the collection. for example the first few are :
We need to rework slightly our node tree.
I won't go into detail in the loop so you can just follow the screenshot :
Add a "Script" node. Select your newly created script and set the input and output names exactly like in the code else it won't work. Place an invoke node to your script, and plug it like so :
Result :
Beware, it kind of crashed when I tried to add another wall blueprint element.