Tank track rotation

well I think this video kind of says what needs to be said…
which is on my vimeo channel along with the tutorials…

https://vimeo.com/102887838

but if you need a file… PM me and I should still have the file that went with that video…
I will need some time to find it…
it’s probably backedup on a CD rom some where…

also theres this one that is a more advanced Rigg

https://vimeo.com/101264384

For the rotation problem if I am following this correctly, unlock all of the location channels on the curve. When you rotate from a remote center you are rotating and moving.

Of course now that you have it rotating it is throwing off the transform constraint. Even though it is set to local.

I have not rigged a solution for this myself, but from memory other other people trying, what you have to do is be able to calculate the path of a the curve. I don’t mean the track curve. I mean the curve or path along which the tracks are traveling.

And because this path is not a straight line, you have to be able to calculate the distance on the path traveled, along its curve which is not the same as through world or even local space.

That distance then drives the rate of rotation along the curve of the tracks.

And since you have two tracks right and left, you have to be able to calculate two paths. Because the tracks will travel along their own paths at different speeds in a turn. And even in some cases, pivot around one track. And even at a times the tracks can move in opposite directions allowing the tank to spin.

I have seen people do this , but it is not a simple set up. And I am really no rigging expert. But I am sure you could do it with a bit of ingenuity. :slight_smile:

EDIT: Yeah just saw that last video. Illustrations the solution very well. :slight_smile:

The behaviour is exactly the same without the location (and rotation) constraints. Actually, I only added those constraints to the simple example uploaded here (and overdone it, yes :o) to make the intended use clearer.

I tried that with a few approaches, but could not make it work. Basically, I mostly tried to circumvent the imo faulty rotational behaviour by working directly on the matrices using Animation Nodes (drivers will be ignored by SheepIt), but as said, did no succeed. Apparently, I am lacking “ingenuity”. :frowning:

If you have any sources where someone actually made it work, I would gladly take a look at it!

I would love to see a .blend of a working tank model. I have gotten close - but the rotations always go wonky for me.

Here’s a thread of my attempts: (with a blend link for anyone to try)

Wow, how did I not find your thread before? You ran into the exact same problem as I did. If I knew how to make a video for that, I would have done it.
So for everyone who is not quite sure what the problem is, watch cadaeis video on his thread! :slight_smile:

Oh… I didn’t realize that you guys were trying to use the two paths (curves) to control two separate Tank Treads method…

that won’t work on my system of doing Tank Treads…

Because I have my treads controlled by the One Tank Hull…

and have never used a path to animated any of my treads… but usally…
a path wants to you to use the ‘Y’ axis as the front to back axis…

but just using one Path to control where the Tank Hull goes would be the way I would do that in my system…

First. Yes. The constraints have nothing to do with it.

Take any object, lock one of the location values and then rotate it from a remote center. That is the rotation issue you have - I think. It has nothing to do with your rig, the curve, constraints or anything.

As to a solution. If it were me. I would fake it. There is no easy solution when it comes to rigging. I think it could be done. It is just above my pay grade and patience.

But I do understand that rigging is a matter of breaking things down to their component parts, and then joining those things together. It starts to get complex as things have to have dependencies on one another and you find that something works on paper but simply does not work at all in a real situation. And sometimes you connect one thing and the whole works goes to hell and you have to rebuild again with another concept.

So then ask if what you need to do is animate several minutes of tanks, or if it is just a few shots. If ultimate flexibility and iteration is important and freedom while animating is most important then it is worth the time to come up with a great rig.

If not, I would simply have a method to animate the tracks and wheels. For that a simple rig and constraint could be used so that no matter how fast the wheels go, the track stays in sync, or the other way around. Probably some way to make a driver or something like that.

Then I would animate the tank separately. Have the tracks parented to it. Once I got the animation of the tank how I wanted it, I would come back and animate the speed of the tracks to match.

This is assuming you want to do more than go straight. That you wanted pivoting and turning and all of it.

As far as other sources it was LightWave. And I think Blender has a more flexible system - if you really want to go hard core.

But I think you are going to have to dig much deeper than you have.

I have to agree with Richard Culver here…

After having played around with my own setup for some time today…
I have come to the conclusion that perhaps the problem is just simply is in the animation Techique…
not the Rigging…
that is… you must have enough key frames in your animation to really get the Tank Track Effect…
if you watch some videos of Tracked Vehicles there really is a different motion that gets engaged in order to move about in a Track as opposed to something with Wheels…
That is basically when moving strait… it’s just like a Wheeled Tank…
but once you go into a turn… that Track has to slow down (that is take extra keyframes to make that Rotation… or else you get sliding…
watch some Tracked Vehicles moving fast and you will note that if they try to turn fast… there is sliding going on…

So I think really throwing in more key frames and adjusting where the Hull should be in that inbetween frame is really the real solution here…

Well, in the end I want to have them controlled by the hull, too; but for testing that is not necessary yet.

I played around a bit with your setup, and it turns out that it works only on the Y axis. I even made a video for demonstration: https://youtu.be/JKAH_8g-y0U :slight_smile:
Here you can see that with your original diagonal rotation the rotation “floats” (for lack of a better word) over the ground. Rotated along the Y axis, the rotation is perfect; but rotated perpendicular to the Y axis, no rotations occurs at all.

The reason is that on your driver you use the global Y position, not the local one.
However, changing it to local puts you into the exact same situation that we are in, with the rotation getting messed up the further you are from the center.

You can see the floating effect also in the second video you linked to here, at least after rotation.

Unfortunately, a tank rig that works only in one direction is not sufficient for me, at least not in the long run.

Thanks for your support and effort anyways, I really appreciate it.

Sure, like I said. If you want to make this work, I think you can. But start with smaller components. Don’t shoot for one solution - constraint, modifier or whatever, and one driver on the tank body, expecting that to work.

Break it down.

  1. You need to drive the track rotation from a path that is moving dynamically on all axis. Basically a curve. So you need to get distance and speed along that curve.

This is not the same thing as a wheel or anything moving in a straight line. Which is all you have tackled at this point. Just trust me here. That won’t work. So put that solution to bed.

  1. Wheels of the track and the track rotation. This is a separate calculation.

If it were a wheel in a straight line, that math would be pi (distance around the circumference of the wheel based on its diameter) plotted against the distance on a straight path to give back a rotation value over that distance. I am sure that something similar would work for the gears of the track. Distance of the length of the track against pi for each wheel would turn back its rate of rotation. Smaller wheels would move faster etc. There may be simple ways to drive this where the math is hidden. But however you do it, this is a separate calculation.

  1. Distance from contact point to contact point of the track where it hits the ground. Or as in your example, rotation around a curve based on its distance. But that won’t work here. It is not based on transforms, X,Y or Z. But rather the collected data from all three plotted into a dynamic vector, some kind of trigonometry or something. I don’t know. I flunked math… lol. And again there may be some way to do this with math hidden. Obviously animating something along a curve takes care of all of this automatically and we never see the complex math behind it. But this only works for a predetermined curve and is but only one component of the entire rig.

  2. A local position null for each tank track left and right. With a null in the center, driving and rotating each. For example the tank body.

  3. A way to calculate the remote path (X Y Z trig) of each tank track based on its position from the driver null. So if you rotate the driver null the vector along the resulting path of each tank track null (not the driver null) and continuous orientation along that path for each. So two paths separate from the driver null. The driver null path is completely there to create two separate paths that move at two separate rates of speed in a turn. And each track mechanism would then be driven: track distance, wheel rotation, from this value.

  4. A way to hook all of this up and be driven by the main tank null. But also avoid cyclic dependencies and drivers and constraints and other tools that simple don’t work together as expected once you connect them. And I think you have seen this so far. One thing that seems to work, but added to something else , like rotation, breaks down.

So you want this, you are going to have to work at it. Otherwise. keyframe it. Work ahead of time or during animation. Your choice.

I decided to throw my little bit of experience into the mix and hope nobody minds. :slight_smile:

First I have to say that I am in complete agreement with everything the experts have said here, particularly the bit about it not being easy to do this at all. Getting the tracks to move properly is penance enough without having to get the track pads to stay distortion-free as they wind their merry way around the curve…

But one thing occurs to me, why not break it down to a mathematical problem, in in that I see three basic scenarios - the tank is moving in a straight line, the tank is rotating about its centre, the tank is rotating about a point to the left, or right of the tank. Each one has a mathematical solution to how much the tracks should move. Possibly the two rotations could be made into one scenario, needs more work here.

So lets take any solution, the tracks have an array mod, then a curve mod and move in one deformation axis. So let’s line the tank up along the Y axis, for no reason at all and let’s parent the curves to the hull and also the tracks to the hull - madness in most eyes I know, but bear with me.

So, scenario 1; the tank moves along the Y axis - if the tank moves 10 units, the tracks move back 10 units, so the bottom tracks stay still on the ground. Now lets move to the X axis, just rotate the tank 90 degrees and move the tank 10 units in X and the tracks move back 10 units in Y, this is still the curve mod deformation axis. Maths is easy, just reverse the tanks movement. Now lets turn it and move it 60 degrees to the Y axis - this time we can use an Empty at the start of the movement and measure the distance away from the empty as we move the tank, then move the tracks back the same amount - maths is easy still, if we know the distance, or it’s vector maths for us… :confused:

Next, scenario 2; the tank rotates around its centre - if the tanks tracks are 2 units away from the centre of the tank they will move rotated_angle * 2 units backwards on the inside track and the same forwards on the outside track, or the other way around depending on which way the tank turns.

Then, scenario 3; the tank turns around a remote point, the centre of the tank will travel rotated_angle * radius of turn - so the next step is that the tracks are spaced from the tank hull, so the inside track travels at rotated_angle * radius of turn - half track width and the outside track travels at rotated_angle * radius of turn + half track width, maths is still quite simple. All we need to do is to know which side the centre of rotation is so we know which track to slow down and which to speed up. Both turn scenarios rely on using Radians for angles, not degrees, degrees just make the maths more complex.

Here is the first image:


@norvman will recognise the tracks, why re-invent the wheel? The best way I know to implement the maths easily, well relatively, is to use Animation Nodes, here is the node tree I threw together:


There are some fairly complex expression nodes in there, these are used to control the various scenarios, including one that is used when you switch from left to right turns - this is either 1, or -1 so the differential on the track movements is correct., there is a little number node on the left to set this, we could measure which track is closest and make this automatic, is it worth it? probably not.

Now we come to using the setup, the “hull” empty is moved in a straight line and the tracks turn, this is calculated by the distance from the “start” empty. When you want to execute another manoeuvre simply move the “start” empty up to the tank over 1 frame - no-one will ever notice…

Next, you want to do a quick centre spin - just rotate the “hull” empty and the tracks turn one forwards, one backwards at the same rate.

Then you want to turn about a remote centre - move the “centre-turn” empty to level with the “hull” empty at the required distance away, parent the hull empty to it, or use a Child Of constraint, then rotate this empty and the tracks move proportionally to their distance from the centre of rotation.

AN takes care of it all, here is the tank on a curve showing how much each track has moved in the boxes in the Node Editor window:


Or you have to keyframe the whole bloody thing bit at a time, the maths certainly helps, but as the wise sages have said - “There is no easy solution”.

Let me know what you think, I could then discuss making the project available.

Curiously enough, the reason why the maths works is because the tracks are parented to the hull as well as the curves, then I move them afterwards with mathematical operators.

Cheers, Clock.:wink:

BTW, wheels on the tank have been covered perfectly well by Richard and others, just use the distance moved divided by the wheel radius to rotate it the correct amount.

I need to clarify this:

Curiously enough, the reason why the maths works is because the tracks are parented to the hull as well as the curves, then I move them afterwards with mathematical operators.

I meant that both the curves and the tracks are separately parented to the hull, sorry for my inaccurate English!

Cheers, Clock.

Impressive. Not sure if I will have to test it. But funny you should pull Animation Nodes out of your Utility Belt. After my long theoretical diatribe I was thinking… hmm… Animation Nodes maybe?

^^ Thanks Richard, I thought AN would be a good starting point.

OK, I tried a little experiment, I thought “What if I just keyframe positions for the tracks and then get a script to interpret where the tank hull should be” so I did just that: :yes:


The node tree is here, just something I knocked up quickly, I’ve not had time to tart it up:


I am not showing the script just yet, not entirely happy with it as I only had a couple of hours development time on it.

So far the tank will go forwards, backwards, spin on the spot; where both tracks are turning, at equal speeds in opposite directions. Then it can spin on one track; where one track is still and the other is moving. It can also go off at an angle, so doesn’t have to follow any axis, let alone the curve deformation axis. Yet to do is to make the tank go around a curve, where one track is going faster than the other and the script will workout the centre of rotation and use Trig functions to move and rotate the tank hull.

Tracks and curves are both parented to the hull and I use two Object Input nodes per track, one reading the position of the tracks one frame ago so I can work out the speed of the tracks from that. There are lots of debug boxes on the node tree, so I can see the track speeds & offsets and see which part of the script is being executed. Lots of debugging and testing to go before I could call it anywhere near done.

Here’s the little tank, thanks to @Norvman for the tracks and curves by the way: :smiley:


And here’s the inevitable little video: :wink:

Feel free to ask any questions, it just a bit of maths and an “off-the-wall” approach to the problem. :eek:

Cheers ,Clock.

PS. Honestly, I only keyframed the track offsets, everything else is automatic.

Nice work. It make me want to get it in a game engine to see if I could blow something up with the gun. LOL Great job clock!

Looking good. Nice job indeed!

Thanks for the kind words, my friends^^

I have looked again at this and wondered if it might be better to use a curve for the path of the tank, then control the tracks - parented to the hull again - by a script, here is the tank, it’s grown a few more bits:


I have added a grid to the ground so I can see that the track pads stay still on the ground - the maths is all sorted for every scenario, I think… so here is the node tree:


This one is not just “thrown together” I actually lined everything up and labelled some of them so I know what they are doing! whatever next - documented code by Minerva!

I look s like a lot stuff, but most is to get distances between objects and delta movements per frame - the script caters for you spinning the tank on the spot and any radius turn, even less that the track width. I used similar principles to my car, bike, coach, aeroplane, etc tutorials on my website to get the angles and offsets, but added a bit of clever stuff to work out the radius of the curve - needed for varying the two track speeds on corners and which way it is turning, one more picture of that:


The highlighted empties do all the work and I have to work with Matrix_World.Decompose() to get the real world values out as they operate as children of moving objects tied to a curve, which moves the planes in one axis only.

I am going to cook another video of the tank in action, which I will post once it is done - this seems to be the most reliable and easiest (Ha Ha) :eek: way forward to overcome the problems associated with the tracks NOT being parented to the hull and as a result, wondering off at times if you push rigs, including my previous efforts, too far. I have 33 lines of code to cater for all the possible curve combinations, including debug code to output values for me to scrutinise. :stuck_out_tongue:

I am conscious that I may be treading on toes here, by suggesting alternative methods to the established wisdom, but the various ones I have tried seem to stand up to scrutiny, although the option of just keyframing the tracks proved to be doable, but over-complicated to sort all the maths out. I hope this experimentation will be received in the spirit it is intended. :yes:

More later once testing is complete. :eyebrowlift2:

Cheers, Clock. :eyebrowlift2:

Well… I hate to say it but…

After calling on clockmender’s testimony I rest my case :smiley:

Point being there can be no other spirit to take this in other than finding a solution. No toe stepping I can see. :slight_smile:

@Richard - yes I think we can both rest our respective cases, if anything is worth doing and can be done quickly and easily it is not worth doing… :wink:

I left my video cooking last night, only to find this morning that although the animation works fine in the viewport, when you Render Animation, the tracks go too fast. :mad: I think I need to investigate “Animation Node Execution Triggers” to solve this, which will take little while and then I have to reprocess the video. Such is life. The reason is that I am moving objects based on their current position plus a delta, so the code goes something like this:

obj.location.y = obj.location.y + d

Therefore I think that AN executes multiple times per frame when you render animations, even though I have it set to execute only when the frame changes - life’s a good learning curve. I looked in the AN Docs and it tells me how to set execution triggers, it does not explain why they are needed, so I am doing a little investigation work. :yes:

Incidentally my latest method, to use a curve and power the tracks with a script works without error if you spin the tank hull many revolutions on the spot, with one track going forward and one backwards - I know the dreaded “180 degree issue” has plagued many of us, including me, so I think I might have solved that little problem. :spin:

Cheer, Clock. :slight_smile:

PS. I am going out with friends for lunch and bearing in mind the parlous state of my health at the moment, am going to get properly pissed, so I may not be capable of any further development work this afternoon. :stuck_out_tongue:

PPS. This appears to be solving the issue:


So AN only executes if the object “Cube” either moves, or rotates.