0
$\begingroup$

Okay, basically inspired by a tutorial for a procedural Belt drive, In geometry nodes I have constructed a rudimentary Tank tread setup enter image description here

What I want to do is configure it so that when the tread objects move then it drives the effect; in effect as the object moves on the local Y axis, the instanced cubes move to give the impression of tank tread movement. Now, I can achieve this effect if I am individually moving the object itself, however if I parent it to another object, in this case a central empty, in a more practical example it'd be some form of tank mesh and move that object the driver will not change value, thus not drive the effect.

In theory I can use the world space, but obviously the effect breaks if you rotate the effect, you could just use the parent for the driver, but when a treaded vehicle turns, one set of treads goes forward, one set goes backwards, an effect that would be impossible that way. is there a way, either through drivers or geometry nodes, to control the tread effect relative to the object's movement based on the obejct's local movement factoring movement driven by objects it is parented to.

Update: After about half an hour of tinkering I have got to 90 percent but the last bit still eludes me.

As you can see I have a total of 5 empties; two axis ones aligned to the origin point of each tread, two circles aligned to the exis empties, and one sphere empty positioned as the 'body between the two treads.

Now the circle empties are configured with a transform constraint set to their respective axis empty so that when the axis travel one meter on the local Y axis, the circle rotates on it's local X axis, which within the node tree has been hooked up to a separtate XYZ, with the X axis rotation powering the tank tread effect. the axis Empties are then parented to the sphere empty using a child of constraint (please note: this is essential, the effect is neutralized if one attempts it with the base parenting it must be a constraint) with the Circle empties parented to them (this can be done normally)

Not only does this achieve the desired effect that the treads run when I move the sphere empty as one would expect, but as I rotate the sphere, the different positions of the axis empties in comparison to the sphere empty mean the circles rotate in opposite directions, meaning the treads move in opposite directions, all of which is accurate to how tank tracks actually behave when turning.

however if I turn the sphere 90 degrees on the z axis by 90 degrees the circles cease rotation when moving on the Y axis, having performed further tests it seems that, despite constraint being set to local space and the axis empties registering the same local orientation as the parent empty, the Transform constraint seems to register the world alignment for some reason, with te effect only working now if you move on the X axis, at which point the 'tank' is moving sideways.

Can someone figure out a way to make the constraints actually work regardless of the rotation of the parent object?

enter image description here

$\endgroup$
4
  • $\begingroup$ Although this has the added detail of GN, this is a duplicate of blender.stackexchange.com/questions/109762/… , and the short answer is, you cannot. The rotation is not a function of where it is; it is a function of where it has been, and this cannot be kept track of with constraints or GN or any combination of the two. I'm starting a close vote on that basis. $\endgroup$
    – Nathan
    Feb 27, 2023 at 15:36
  • $\begingroup$ Does this answer your question? Making wheels spin as car moves on local Y axis $\endgroup$
    – Nathan
    Feb 27, 2023 at 15:36
  • $\begingroup$ By that logic what I have put together here actually functions as an alternate option to bypass the limitations of the Transform constraint, as I have experimented to develop my answer it does allow me to transform an object in one way based on, functionally, the local translation $\endgroup$
    – medafan53
    Feb 27, 2023 at 15:49
  • $\begingroup$ Control shape keys with drivers to the speed of rotation $\endgroup$ Feb 8 at 10:41

1 Answer 1

0
$\begingroup$

Okay, this Answer is not to the revised title regarding the transform constraint, however I have (finally) figured out the missing piece to make this effect work. which could also be used for similar things, such as using geometry nodes to rig a wheel's rotation based on it's movement.

enter image description here

As you can se, what you want is to add an object info node and the plug a self object input node into the object socket. This sets the object info node to capture the transform data from the object your node tree is attached to. From here you need to take the location information, plug it into a separate XYZ and plug whichever direction is pointing forward if you click on your object while set to local transformation, and that will run your treads effect. However you will then still see the effect cut out if you turn 90 degrees, because it is effectively looking at your world transforms. So plug a vector rotate between the object info and the separate XYZ, set it to Euler and plug the object info rotation info to the rotation slot. Now the effect will run no matter which direction the object is rotated.

enter image description here

However the effect is still not perfect; if you rotate it 90 degrees then it will actually have turned 180 degrees and the effect will be backwards. Instead you want to put a vector math node set to scale with a factor of -1 between the object info rotation output and the Vector Rotate node.

An additional factor I have worked out is how to get the speed right, what you need to do is get a curve length node and plug it into a From Max socket on a Map Range node, which replaces the previous divide node (socket the separate XYZ node into the value node), which will mean that moving the tracks the full length of the curve will cause on instance to travel all the way around the curve.

To adapt this to a turning wheel instead, you need to use the bounding box node to calculate the diameter, use that to calculate the circumference of the wheel using math nodes, plug the result into the from max socket, put 360 into the To max, plug the map range nod into a Math node set to "To Radiens" and plug that into a combine XYZ node plugged into a Transform rotate node, based on the axis you need the wheel to rotate around.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .