Keep up-to-date with Free tutorials!!


Sign up to our twice-monthly newsletter today for the latest tutorials, interviews and product information.

Sign me up to receive third-party emails from 3dtotal's partners, too!

- Latest news
- Exclusive Shop Offers
- Preview early content
- Plus much more


Not Ready to take that step? OK, Why not just Subscribe to the RSS Feed

submit tutorial
1 | 2 | 3 | 4 | 5 | 6 | 7
Tank Rig Tutorial

| Your Rating:
rating star fullrating star fullrating star fullrating star fullrating star full
(Score 4.75 out of 5 after 12 Votes)
| Comments 2
Date Added: 9th December 2009
Software used:

Caterpillar Pieces

The pieces will slide using a path constraint over the spline that we have created, then we'll add a script controller in its percent along path controller to define its sliding in respect to the distance travelled by the tank.

Unhide by name the Caterpillar_Piece_01, link to the Frame and add a path constraint to it using the CaterpillarSpline as target. In the motion panel in the path parameters rollout set the parameters as shown in the picture. The Allow Upside Down option will enable the piece to have the right orientation through the spline without any flipping.

Then rotate the piece -90 degrees over its local x-axis and then -90 degrees over its local z-axis.

Now, we'll add the script to the percent controller. In the motion panel -> Assign controller rollout (you can also do it in the track view) assign a float list controller in the percent controller, in the list's available controller assign a Bezier float controller, and in the First controller (Linear Float) assign a Float Script. We created a list of controllers to define an extra value with the second controller, so, in this way, we can define an offset to each caterpillar's piece having the same script controller for all of them.

The script is almost the same than the wheel's spinning. But in this time we're not using a radius, instead, we'll be using the Caterpillar length. Start writing the first line of the previous script:

SplineLength=curvelength Path

Then add the next line after the first one:

CatLength=curvelength Caterpillar

In the last line replace radius by CatLength and place a minus at the beginning of this line:


And don't forget to create the variables and assigning their respective nodes or tracks. In the Caterpillar variable we need to assign the CaterpillarSpline as node.

In this case we're finding the number of the piece's turns along the caterpillar dividing the distance by the caterpillarLength (the perimeter).
This is what the controller handles, a value from 0 to 1, 1 as 100%, in this case as 1 turn along the spline.


Cloning the Pieces

To clone the pieces we need to do the same process 50 times!.

Fortunately, there are methods to do it very quickly, an iterative macro operation. As I said in the first page, it means to make a lot of repetitive tasks in a few lines of code.

Go to Maxscript Menu -> New Script. In the Text Field paste these lines of code:

for i=1 to 49 do
newPiece=copy $Caterpillar_Piece_01
newPiece.position.controller[2].percent.controller[2].value=(i/50 as float)*100

How it works:

for i=1 to 49 do

First, we need to define the iteration range using the sentence "for", using the variable "i" we start defining the first number of the iteration, in this case we start from 1, and then defining the last number of the iteration, in this case 49, we'll be executing the same process 49 times. Inside the Iteration the current loop number is stored in the variable "i", we can use this number to set a percent offset in the current piece copy.

Between parenthesys we describe the process that we need to repeat 49 times.

newPiece=copy $Caterpillar_Piece_01

In this line of code we're creating the copy of the piece and storing it in the "newPiece" variable, we need to use the "$" character before the object's name to be able to use this object inside maxscript. If the object's name has any space on it, in maxscript we need to replace this space by the "_" character.

newPiece.position.controller[2].percent.controller[2].value=(i/50 as float)*100

In this line we're defining the percent offset. With the dot character (.) I'm accessing into a property, first accessing the newPiece's position property, then the second controller of the position, then its percent, then the second controller of this percent, and finally the value of this controller. I use the variable "i" (current loop) to find the right offset, if we divide this number by the total number of copies we get a value ranged from 0 to 1, multiplying it by 100 we get the percent respective to the current copy. i use "as float" to make sure the division will bring me a decimal number.


This is only one line actually, it was too long. Here, we're copying-instance the first percent controller, the script controller. If we'll need to make any configuration to this controller in the future, we'll need to make it only once. And also there's only one script controller executing only one time giving a value shared for all the pieces.

After you place the code in the Text Field of the maxscript editor go to File->Evaluate All. Now we got 50 pieces!
This is just a very very tiny explanation of iterative macro operations; you could check the Maxscript reference for a lot of information about this. Also, you could use the Macro recorder to find the maxscript code for an operation in max; you can activate it in the Maxscript menu -> Macro recorder. It enables a pink Text Field in the Maxscript Listener (Maxscript Menu->Maxscript Listener). If you made an operation in max the script will appear in this text Field, unfortunately not all the max's operations appears there.

Join us next week when we wrap up this tank rig with creating a fullt movable turret and cannon.

< previous page continued on next page >

1 | 2 | 3 | 4 | 5 | 6 | 7
Related Tutorials

Making Of 'Ready to Go'

by Jaime Otegui
published on 2009-12-09

Keywords: scene, vehicle, bike, vespa, garage,

rating star fullrating star fullrating star fullrating star fullrating star full (5)
Comments 1 Views 62742

Making Of 'A Mazda CX-9'

by Michael Seidl & Bernhard Rieder
published on 2009-12-09

Keywords: scene, vehicle, car, city, wall,

rating star fullrating star fullrating star fullrating star fullrating star none (4)
Comments 1 Views 80179

Car Modeling Using Nurbs Part 4

by Julian Sarmiento
published on 2009-12-09

Keywords: vehicle, car, wheel, rim,

rating star fullrating star fullrating star fullrating star fullrating star half (5)
Comments 0 Views 110043

Making Of 'Blowout at Exit 16A'

by Till Nowak
published on 2009-12-09

Keywords: scene, vehicle, car, character, futuristic,

rating star fullrating star fullrating star fullrating star nonerating star none (2)
Comments 0 Views 100108
Readers Comments (Newest on Top)
Strob on Tue, 29 November 2016 7:48pm
Hi, nice tut! Can you tell us how would be the best way to scale that entire rig?
John Nulty on Sat, 30 April 2016 3:15pm
Great Tutorial, just some parts i am struggling with. Would you please do a video tutorial for the tank rigg? Thanks
Add Your Comment..