This tutorial was originally printed in 3DWorld Magazine back in January of 2009 – over 10 years ago as I write this now in October of 2019. It was originally called “Is there a simple flocking procedure in Maya?” (version 8 at the time) a question sent to the Magazine by someone called DuneBug73. The answer at the time was “not really.” You could make a passable pipe of particles at the relative press of a button, but the process of animating birds with enough randomness to lose the 3D-ness took a little longer. Now we have both fluid particles and MASH in Maya making this sort of process a lot simpler to produce and control. Still, as tutorials go, it’s a nice introduction to using the original particle system and expressions.
If there are two words that I would never, ever put together in a sentence referring to Computer Graphics, unless I was prone to creating oxymorons, they would be ‘simple’ and ‘flocking’. There is nothing simple about flocking. Nothing at all.
Quite honestly, if I had to make a system of flocking objects, I would fly like the wind to www.highend3d.com and download the brainbugz1.3.3 plug-in created by Carsten Kolve (www.kolve.com) rapidly applying it to my scene and then sitting back to watch it make pretty particle patterns on my lovely big widescreen monitor. Hmm, shiny… However, the point of the question was how to create a simple system, and so a simple one is what we will create. So, how about a flock of starlings, my darlings?
Now hold on, I hear you all cry, that’s a hell of a lot of starlings. Don’t fret it, we are only going to make a few hundred of them, but the flocking patterns of a starling are really great as they show a high level of conformity, and this is really quite important if you want to create a simple system. To do this, we are going to use Maya’s goal weights to drive the motion of a group of particles which in turn will drive a series of cyclically animating objects simulating actual bird flight. Don’t worry, it is a lot simpler than it sounds. Well, simple is the name of the game in this instance – excuse the pun – but impressive is what we hope to achieve.
We’ll begin by creating a simple ball of particles and then a sphere which we will turn into a goal object. Think of a goal object as a magnet, the power of its attraction set by the attractors rather than the magnet itself. To add some discontinuity, we will then push some forces at our particles.
Once the initial motion is about right, the next step is to take our basic bird shape and using some bones, animate a simple flapping motion. Creating duplicate shapes for each pose in our animation cycle, we will then be able to add all of these as an instance group and cycle through them making it look as though our birds as really flying around. It’s a lot easier than it sounds, honestly. And it really can look very impressive. Let’s get to it, shall we?
Open a new Maya scene.
Yup, I like to start from nothing.
Now change to the Dynamics menuset and from the Particle menu select Particle tool > Option Box.
Under Conserve, set the number to 300 and the radius to 10.
Now Click as close the Origin as you can then press Enter.
In the Channel Box set the particle1Shape’s Particle Render Type to Spheres.
Hey, it’s a ball of balls!
Create a polygon sphere, holding down X to snap to the grip in the front orthographic view.
Now in the polygon sphere’s inputs, set the radius to 10.
Change the subdivision axis to 20 and the subdivision height to 15, giving a multiple vertex count to 300 to match our particles.
Create a CV curve in the top view that curves over itself, I made one like an ampersand.
Now in the other views, using Maya’s soft selection radius adjust the CV positions until you end up with a swooping curve that we will use as a motion path to animate the ball.
Adjusting the Animation and influences
Reset your timeline to around 200 frames.
Select the sphere and the curve then in the animation menuset, select Animate > Motion Paths > Attach To Motion Path.
Playback your animation and the ball will be attached to your curve.
But it’s motion is very linear and not at all swoopy.
Open up the graph editor and select the sphere.
In your graph editor, select the motinPath’s curve.
Now select the add keys tool and MMB click on the motionPath’s animation curve where the ball reaches peaks in its motion.
Adjust the bezier handles so you have slower motions into and out of these points.
This should give your ball a more weighted animation.
Change to the Dynamics Menuset.
Select the particles and then the sphere followed by Particles > Goal > Option box.
Making sure the goal weight is set to 0.5, click Apply then close down the option window.
Playback your animation and you’ll notice your particles looking like a bouncy ball following the ball, trying to stick to its vertices.
Change your channel box to an Attribute Editor, by clicking the Attribute Button at the top right of Maya’s interface.
Select the particles.
In the attribute Editor, you can see a setting called conserve.
Setting this a little lower will reduce the amount of bounciness in your particles.
Set it to around 0.9.
To add some variety to the individual particle goal weights, move down the Attribute Editor until you see five oblong buttons in the Goal Weights and Objects rolldown menu.
Click the button marked Create Goal Weight 0 PP.
This creates an Array Attribute further down the editor.
RMB click over the new Goal Weight 0PP attribute and in the pop-up select Creation Expression.
This will open the Expression editor for the particle.
Type in: particleShape1.goalWeight0PP = rand(0.3,0.8);
Playback your animation and some of your particles are now trailing behind the others.
Creating More Realistic Results
Go back up to the Goal Weights and Objects rolldown.
If you put the Goal smoothness to 0, all the particles lose their lag and lock to the sphere.
For a laugh set it to 10 and playback the results.
To get some lag, set the value to around 4 and playback these results.
Now some more variation.
Select the particles and pick Fields > Turbulence.
Set its magnitude to 500 – that’s not a typo – and it’s attenuation to 0.
Set the timeline to end at around 300.
Playback your animation and you’ll see that there is a far greater variety of motion.
After frame 201 you’ll see the particles trying to lock onto the sphere, but the turbulence keeps pushing them about, making it look more like a swarm of bees.
Select the sphere and set its visibility to 0.
Playback your scene.
Some of the particles are locked too closely to the shape of the ball.
In the Attribute Editor of particleShape1, RMB click on the Creation Rule we previously created.
Change the high value 0.8 to around 0.4, and the 0.3 to 0.25
Click on the Edit button and playback the results.
Save your scene.
Getting into a flap over animation
Open up starling.mb.
Yep, it’s a very simple bird shape. For a flock, this is probably about the amount of detail you would want for a distant blurry object. (The trick here is as long as you get the animation right, you can get away with a lot, or more to the point a little.)
Pressing F2 to toggle to the Animation menuset.
Select Skeleton > Joint Tool and, from the Top View, Pressing X to snap to the grid, create a joint in the middle of the bird.
Continue on the create a shoulder and then follow the second row of vertices from the front of the wing and create an elbow, wrist and finger end effector.
Raise joint1 up to about shoulder height of the bird.
Select the shoulder and press insert on your keyboard.
(This has been superceded by pressing D to accomodate both MAC and PC systems)
You can now move the joint up and down without altering its transform value.
Continue in this way until all the joints are in the wing.
Press Insert again exit the transform offset mode and lock their transforms.
Select the shoulder joint and select Skeleton > Mirror Joint > Option Box.
Set the Mirror across to YZ leaving Mirror Function to behaviour.
This done, select the bird, then the joints and select Skin > Bind Skin > Rigid Bind.
Save the scene.
We are now going to animate the bird to make shapes that will be applied as cycling instances of our particle later.
Use the Edit Membership Tool in the Edit Deformers menu to adjust those vertices that are being moved by the wrong joints.
Now pose your wings so that at frame 1 they are high up in the air as above.
Select the root joint and click Edit > Select Hierarchy then press S to save a keyframe on every joint. Go to frame 9 and save another duplicate keyframe for all the selected joints.
At frame 5, set the wings at their lowest position.
Select the joint hierarchy again and save a new keyframe.
Continue to adjust and save keyframes on the other frames until you are satisfied that you have a birdlike animation sequence.
Now save your scene as starlingAnim.mb.
Now let’s create individual models of the bird for each frame of its animation cycle.
Select the bird geometry at frame 1 and press Ctrl + D to duplicate it.
Select all the locked transforms in the channel box of the duplicate and select Channels > Unlock Selected.
Now move it left of the original bird.
Go to frame 2 and repeat the process of duplicating and unlocking up to frame 8.
Frame 9 is the same as frame 1 therefore we do not need it in the cycle.
Changing Particles Into Birds
Save the StralingAnim.mb again.
Now select all of the duplicates and click File > Export selection.
In the pop up window write out the file with the name birdExports.mb.
Close down the current scene and open up your original particle animation scene.
Now import your birds.
Wow, they look far too big.
Select all the birds, reset their tranformations to 0,0,0 and then scale them down, until their bodies are around the same size as the balls.
Press F5 to toggle to the Dynamics menuset.
Select your birds in order from 1 to 8 followed by particle1 and select Particles > Instancer (Replacement).
Presto instanto, you should now see lots of birds with their wings up in the viewpane.
Open the Outliner and double click on the teardrops by the new object instance1.
N.B. You cannot select an instance in the window.
In the Attribute Editor that pops up, you can see the names of your starlings in the Instanced Objects list.
If any are in the wrong order, move them up or down to make the order correct.
Where it says Cycle above, set that to Sequential.
Playback your animation now and the birds are all flapping together.
Now let’s make them point in the direction they are flying.
Refining Your Particle Instance
In the Attribute Editor select the Tab at the top that says ParticleShape1 and go down to the Instancer(Geometry Replacement) rolldown.
Pop it open and click the box beside Allow All Data Types.
In the Rotation Options, set the AimDirection to WorldVelocity.
Play back the animation and the birds are flying more directionally, but they seem to be suffering from a bad case of crabs.
In the top view, select the original birds that make our instances.
Press F8 to toggle to component mode and then select all of the birds vertices.
Carefully rotate them until the birds are looking down the positive X axis.
If you press J before rotating, it will go rotate in the set increment values of your tool, so the as the default value is 10, it should take 9 rotates to set the birds facing in the right direction.
If you look at your animation now, you’ll find that the birds are all flying the same way as the particles.
Finally to add some variation to each bird, we need to make sure that the wings are not all synchronising.
Select particle1 and in the Attribute Editor roll down to the instance section again.
You should see a section called Cycle Options.
At the top, where it says CycleStartObject change this to particleId.
This means that the first object in the cycle refers to each individual particle’s number.
If you now playback the animation, the results should be far more randomised and, guess what, you’ve got your very first flock of starlings.
Turn off the visibility of the particles, curve and the polySphere and render out the results in your favourite render engine, composite your results and enjoy.
I hope you liked this tutorial, even though it might seem a little dated. The fact of the matter is most of the things in here all still are in Maya and so everything is still relevant and useful. If you like this, please leave a comment below. You can also find my other tutorials by clocking on the Resources button on the menu bar.
Bye for now!