In this tutorial, I am going to show you how to create an animated bars equalizer effect in 3ds max using Maxscript. We can’t create these type of effects manually as they need adjustment at every frame, so, in this tutorial we will make use of MaxScript feature of 3ds max and write a simple and short script (with explanation) to achieve this effect. Let’s get started.
Let’s first create a chamfer box or a normal box primitive and clone it few times by Shift + dragging it. I already have 10 chamfer boxes in the scene.
Now, go to Maxscript > New Script to launch the Maxscript Editor. Let’s write some code.
a= $ChamferBox* as array with animate on for i=0 to 100 by 2 do at time i ( a.height = random 1 60 )
Result and Explanation:
a= $ChamferBox* as array
This line will add all the chamfer boxes to an array. Since, array allows us to modify multiple objects at once, so, Now, We can simultaneously modify all of the chamfer boxes.
for i=0 to 100 by 2 do
We are using For loop to repeat random command several times. During script execution, I want my script to create keyframe after every two frames, so, instead of using i=0 to 100 do, I am using by 2, in the For loop.
at time i ( a.height = random 1 60 )
This code randomize the height (range: from 1 to 60) of our all array elements at every frame.
As we can see that all the elements of the array got random height at every frame but notice that every box has same height value at each frame. Let’s modify the code to make it better and interesting.
Here is the modified version of the script:
a= $ChamferBox* as array with animate on for i=0 to 100 by 2 do at time i ( a.height = random 1 60 a.height = random 1 60 a.height = random 1 60 a.height = random 1 60 a.height = random 1 60 a.height = random 1 60 a.height = random 1 60 a.height = random 1 60 a.height = random 1 60 a.height = random 1 60 )
As you can see I just write each element of the array separately.
a.height = random 1 60
The number in between square brackets represents the array element, so, every time we execute the script it randomize each array element one by one and each box get a different height value at every frame. I have 10 boxes in the array so I wrote 10 lines of code, one line for each box.
I hope you enjoyed this tutorial and learned something new from it. Subscribe for more new tutorials. Thanks.