Creating a Spaceship Fleet Using Particle Instancing in Maya
Application Used: Autodesk Maya
Author: Bogdan Amidzic
Particles are one of the greatest features in Maya. In this tutorial I'm going to show you how to use the particle instancer to create a fleet of spaceships flying across the planes. Also I'm going to show you how to use events to crash the spaceship.
To begin, model a simple spaceship. You can also apply materials and textures to it.
Then from the side view select the spaceship and press Insert key to enter pivot transform node. You can now move the pivot without changing the object's position.
Go to Dynamics menu set. There's particles menu. Go to particle tool. In the tool options you can select how many particles to draw on a single click. Select one, since you are going to draw one by one.
Draw particles in a V shape.
Draw the last particle in the middle.
Press enter. Now you have particle1 in your scene. If you try right clicking on particles, you will notice there's particle selection mode. Select the middle particle. We are going to make it higher than the other particles.
Go to window/general editors/component editor.
In the component editor, go to particles tab, and change PositionY to 2. The particle will be lifted upwards.
Select ship and particles and go to particles/instancer option box.
Delete particles from list
Now you have the fleet
Select instancer and in attribute editor uncheck auto load selected attributes. Now you can select anything without loosing data in the attribute editor.
Create another ship, but make it bigger since he is going to be the boss. Add it to instancer using add selection button. When you do that, nothing will change. That's because by default all instances use the first object.
So in particle shape node scroll down to Per Particle (array) attributes. Hit general button.
Name attribute ID. This attribute will control which object is used for instancing on which particle. So make it float, and check Per Particle (array) since it's going to apply to every particle separately.
Then select all particles and in component editor change id on the last particle to 1. Still nothing will change. That's because the ID attribute is not linked to the instancer.
In particle shape node, under the instancer (geometry replacement) tab change object index to ID. This will link object index to ID. Now you have the big boss.
While particle1 is selected go to fields menu and select uniform field. This field will apply constant movement at every frame of animation. Set magnitude to 10, attenuation to 0, and direction to move your ships.
Now they will move. It's time to add some turbulence to their movement. We are not going to use the turbulence field. Instead we will write a simple expression. Go to Per Particle tab, and in popup menu choose runtime after dynamics. This will apply the expression after the dynamic part (forces).
Write particleShape1.position+=rand(-0.025, 0,025);
This will move particles randomly by 0.025 in positive or negative direction. If you look carefully, you will notice that the particle is moving in all three axes by same number. If you want the particle to move in three axes separately type this: particleShape1.position+=<>
Now create one volume axis field, set around axis to 0, shape to cylinder, and set magnitude to 20.
When ships pass through the field, they'll spin, around the center of the field, but their rotations remain the same. That's because the particles doesn't have rotation since they are just points in space.
To fix this go to the instancer tab and change AimDirection to velocity. This will rotate the instanced objects to the movement direction of particles. In frame 0, you will get some funky rotations. This happens because velocity at frame 0 is 0. To fix that set initial state to some frame where particles move (frame 2 will do fine).
If your objects rotate in the wrong direction you can solve that by rotating the pivot of the object. You can do that by selecting object, hit f8, and click on cross icon. This will display the rotation handle. You can rotate it by 90 degrees by going to options for rotate tool. There's check box snap rotate. If you check it, you can enter 90, to snap to that angle. Then rotate your handle.
The other way is to select all vertices of the object and in rotate options choose component use object pivot. This way you will rotate vertices, but rotation axes will remain in place. Check out the picture below:
Now model some simple terrain. Make an obstacle for some of the ships.
Duplicate polygons on the obstacle (select faces, and then use duplicate faces command). This way, particles will collide only with the obstacle instead of the whole terrain mesh. Select particles and obstacle mesh, and go to particles/make collide.
Obstacle mesh will have new attributes under geoConnector1 node tab. Resilience controls how much particles will bounce from object, friction – how much the objects surface will slow the particles. If you have 0 resilience, the particles will slide along the surface. If you set resilience to 0 and friction to 1, particles will stick on the surface. The only important attribute for us is offset. Offset will control how far from surface collision will be detected. Raise this number a bit, because the pivot on our ship is at the back, so if offset is 0, the ship will enter the obstacle and then collision will occur. This way, the particle will collide when the ship hits the surface.
Then select particles and obstacle and go to particles/particle collision events. Hit create event button. This will create event0, check emit, set number to 1 and check original particle dies. By doing so, the particle will hit the obstacle but it will emit another ship at the same place. This is happening because by default it will emit the same particles. To fix this, create one emitter in the scene. This will also create another particle system (particle2). Delete the emitter. Particles will remain. In the target particle line enter particle2. Now when the ship hits the obstacle it emits one particle in particle2.
For particle2 set lifespan to .2 with random of .1. These particles will remain very briefly. We will use them as spots where explosion will occur.
So select particle2 and go to emit from object. Yes, in Maya you can emit particles from particles. Cool eh?
Set emitter type to omni. Min distance to .5, and max to 1. This will create a sphere of particles. Set speed to 1, with random of .2. Also set the rate to 1000, since this emitter will emit particles for .2 seconds (in time particle2 is active).
So now we have three particle systems. One is ship particle system, second is particle system which marks the spots where collision occurs. And third makes the explosions where those spots are.
Set type to clouds. I will not explain how to use cloud particles. See my tutorial for making rocket trail. It's about shading particle clouds.
When rendered it looks like this. Nothing special, but it works.
Also you make particle1 to emit a trail of particles. Piece of cake.
Well, that's all folks!