Maya Particle change instance geometry in certain places


#1

Hello,*

I am trying to make a simpleParticle simulation where the particleschange instancegeometry, for example:
They start as cubes then when they are fall in the left side hole they became spheres and when the particles fall in the right side they became cylinders at the end when they exit the holes they became a donut shapes.
How to do that?


#2

This can be archieved quite easily.
You need a per particle object id attribute. Let’s say it is called objId. In the creation expression set:

  • objId = 0;
    Next you set the “Instancer” section of your particle shape, you set the “Object Index” menu to objId. For the whole sequence, all the particles should now use the cube as instance object. Then you add something like the following into the particle shapes runtime expression:

objId = 0;
if( position.x > 0.0)
{

  • objId = 1;
    }

Now the particles should change the instance object as soon as they move from negative to positive x.


#3

Thank you*haggi
I did what you suggested it worked
since I am new to scripting I looked around to get the exact writing
finally I reached to this and it worked however it might look not clean

vector $PPos = nParticleShape1.position;
nParticleShape1.custindx = 1;
if( $PPos.y < -5)
{
nParticleShape1.custindx = 0;
}
if($PPos.y < -5 && $PPos.x > 1)
{
nParticleShape1.custindx = 2;
}
if( $PPos.y < -20)
{
nParticleShape1.custindx = 3;
}