The goal of this set of experiments was to be able to control the position or movement of a single clone within a MoGraph Cloner. The system I had in mind when I started these tests was a ligand binding to a substrate, but it could be applied to many different systems.
1. Attractor Field with Random Effectors
The attractor field gets a lot of the work done, and for many cases, this set up is all you need. I have simulation tags on both the clones and the sphere, and an attractor field with a falloff as a child of the sphere.
To achieve the movement I have in this video, I created two Random Effectors, one with small displacement and one with very large displacement. The problem with the Random Effector is that each clone is never going to be able to truly change it's position (to my knowledge). It's not as obvious in the example above, but when you color the clones, you can see they never mix.
2. Plain Effector and a MoGraph Selection Tag (still with Random Effectors)
In this next example I used xpresso to conditionally add clones to a MoGraph Selection tag based on their distance from the Sphere, and then used a Plain Effector to change their position. In this case I targeted their position to the Sphere, but what separates this from the Attractor field example is I can use the Plain Effector to change location in just one direction, like 50cm in the x, instead of all being attracted to the same point.
Here's the important aspects of this setup:
Here is my xpresso setup.
You could of done this with just a Python node but I thought this was visually more comprehensible.
The downside of this setup is it still lacks a true random walk, and I still can't explicitly control a clones position independent of all the other clones, whatever I set the Plain Effectors Transform parameters to their going to be applied to all the clones in that selection. Enter the Dynamic Body State Node (!).
3. Dynamic Body State Node
It drove me nuts that the MoGraph Data node didn't have position as an input port option, but I discovered the Dynamic Body state Node does, and so much more. The "Object" for the input port is the object that has the dynamic tag on it (Dynamics must be turn on), so in my case it was the cloner. The first version I did of this I just tried to recreate the setup I have in the previous examples. You can use the Dynamic Body State node to change the position of a clone, but if you do, it overrides the collision calculation, so your clones will end up intersecting. So I used the "Add Force" and the "Linear Velocity" inputs. I did two different versions, the first one the random walk vector decreases as the cubes get close to the sphere, so they can't come back off the sphere very easily.
if (frame+index)%5==0: #so that every clone does not change direction every frame
if dis< mindis:
randwalk=newclonepos#*pos/mindis #2nd term reduces their chance of escaping
field=spherev*(-pos/mindis+1) #linear falloff
You can download the file to make this video:
I then set up a nested iteration so that I could add any number of clones of spheres as well. This enables you to change the number of either clone on the fly and the setup still calculated the attraction appropriately, as you can see in the video below.
I experimented a lot with the different input ports for the Dynamic Body State node, and this setup works well, but if you watch the upper right sphere in the video it seems to attract the cubes more strongly. I've tried rotating the clones and changing the count, so I'm pretty certain it has to do with the Object Index, which makes me think the iteration isn't working exactly how I expect, I would love any insight on that. I also think there is a more elegant way to get a random vector, I just initially saw some bias in the simulation when I had the Iteration going direction into the Random Seed, and it's my understanding that sequential random seeds have similar random tables, so I used a noise node to get a different Random Seed.
Hope you enjoy!