Instancer Example

Say for example you have 10 objects selected that you want to instance onto your particles. They will be listed in the "Instanced Objects:" window as 0-9. In order to assign the geometry to your particles, you need to create the link so it randomly selects from your list of objects to place onto the particles. To do this you need to open the partile shape node in the Attribute Editor and scroll down to the "Add Dynamic Attributes" section and click [General]. Add an attribute under the "New" tab called custom_index and make it a float, per particle attribute. This will create a new attribute and apply it's float value to each particle at birth. Now back in the Attribute Editor you should see the "custom_index" attribute in the "Per Particle (Array) Attributes" section. If you do not see the attribute click the [Load Attributes] button at the bottom of the Attribute Editor and it will refresh the list. Right click in the field to the right of custom_index and select "Creation Expression..." from the list. Now in the Expression editor you want to write the following expression:

particleShape1.custom_index = rand(0,10);

Note that the list of objects is 0-based. Which means the first item listed is index-0. The reason you use rand(0,10) is because the list is a 0-based array and Maya will simply truncate (round down) the return value. So, if the rand() function returns 9.999, Maya will evaluate that as 9. The odds of getting a return value of 10 is slim-to-none. Therefore when dealing with creating a custom index you use rand(0,total number of objects). Back in the Attribute Editor you want to open the "Instancer (Geometry Replacement)" tab and set the "Object Index" to custom_index in the drop-down field. When you play your animation the particles should now be randomly represented by your ten different objects.

Back - Page 3
Jump to Page: 1, 2, 3, 4, 5, 6