SubComponent Position - Constrained vs. Floating


Doing a bit of a test to find the limits of Dynamic Components and have the following logic problem:

Is there a way to make two components interact? For example, two small cubes, say 12" per side. Box1 and Box2. These would be sub-components within a larger component. When I move them around in the sub component, they are free to move unrestrained as long as I don’t put anything in the position variables. But what if I wanted them to be free to move unless they were within a certain distance of each other? So if I moved them close, or rather moved one close to the other, it would snap to align with the other object if it was say within a foot of the other one.

Restrain the discussion to just two, unique components and it seems quite easy - set the Box2 position to be X variable: = if ( abs (X-Box1!X) < 12, Box1!X, current(X) )

The problem is, this code doesn’t work. It throws a circular reference flag, which is accurate. Also, I don’t think I’m using Current(X) correctly - but can you see what I’m driving at?

Any insight would be much appreciated. Maybe I’m trying to do something that isn’t available. I have also thought about passing the current location to a temporary variable, then referencing it to update the position. I don’t know - a little lost here.

Also this feeds into a larger discussion which is that it would be impossible to make this work if there were more than just a few boxes - as you’d have to program the behavior into all of them and that would become a PITA quickly.


a few of as played with this concept last xmas…

not the same, but it was fun…