Keep up-to-date with Free tutorials!!

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

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

By Felix Rodriguez Joleanes
| 209004 Views
| 0
Software used:
3ds Max

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:

-(Percent/100)*SplineLength/CatLength

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
newPiece.position.controller[2].percent.controller[1].controller=
\$Caterpillar_Piece_01.position.controller[2].percent.controller[1].controller
)

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.

newPiece.position.controller[2].percent.controller[1].controller=
\$Caterpillar_Piece_01.position.controller[2].percent.controller[1].controller

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 next page >

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

Tutorial

Gallery Image.

Keywords: car, vehicle, green, rogue,

(5)
2 54445

Tutorial

Gallery Image.

Keywords: Maya, rigging, animation, character, vehicle

2 71738

Tutorial

Gallery Image.

Keywords: Maya, Rigging, Hands, Fingers, Thumbs, Animation

1 22440

Tutorial

Gallery Image.

Keywords: Corona, Renderer, Car, Paint, Video, 3ds Max

0 6589