PDA

View Full Version : something like gravityPP


bluehonda
02-21-2011, 04:44 PM
hello everyone,

i need a little help on this expression I 'm trying to write. and hope people here can help me out. i basically instanced a whole wall into particles and placed a volume axis field as my explosion. so i need all the particles that gets blown away by the field to gain gravity. now i just create a gravity field for the particle for it will drop all particles. and using a volume as the shape of the gravity wont work either.

so im thinking of an expression that if my particles velocityY is a certain value, a certain negative amount is added to its velocityY. hope someone can help me out. thanks.

this is what i have so far:( which i think is not really working)

vector $vel = particleShape1.velocity;
if ($vel.y > 1)
particleShape1.velocity += <<0,(frame)+ -9.8,0>>;
else
particleShape1.velocity += 0;

Phlok
02-21-2011, 05:06 PM
Have you tried using an Uniform field instead of Gravity and assigning random massPP values to the particles?

Just like this one:

http://www.thegnomonworkshop.com/tutorials/gravity_vs_uniform.html

republicavfx
02-21-2011, 05:12 PM
look for per particle fields in the help. you can add a gravity field then select it then the particles and say use as source of field or somehting like that. then you add a custom per particle attribute which has to have a specific format... so gravityField1_magnitude or something like that, then you can write expressions or use a ramp.

i use this all the time...its awesome

Aikiman
02-21-2011, 07:44 PM
Both methods would work, I prefer the field_magnitude one myself, its a hidden gem and works for all fields and their attributes, you just have to create a new PP attribute each time - its as simple as that.

bluehonda
02-22-2011, 04:09 AM
Im trying out the field magnitude. And using this expression:


vector $vel = particleShape1.velocity;
if ($vel.y > 5)
particleShape1.gravityField1_magnitude = 9.8;
else
particleShape1.gravityField1_magnitude = 0;


- thou it still drops all the particles. when 1 particle reaches the vel.Y of 5. all particles still get affected by the gravity. So I know there is something missing or wrong with this expression.
- I've added the gravity, created the GravityField1_magnitude attr, used particles as source of field, turned on Apply Per Vertex, and wrote the above expression on my runtime.

republicavfx
02-22-2011, 08:48 PM
im no expert but dont you have to get the magnitude of the velocity first? like mag(velocity)

if (mag(velocity) > 5)
particleShape1.gravityField1_magnitude = 9.8;
else

or something like that..thats psuedo code, lol and maybe im not right about it but i usually always use mag(velocity) for everything

eaclou
02-22-2011, 09:03 PM
edit: misread the post - I'm not sure why it's affecting all particles. I'll see if I can think of anything

bluehonda
02-23-2011, 10:49 AM
so guys what expression would you use? im not really an expression writing expert. so I can't totally figure out whats wrong with the code im using. i tried adding the "if (mag(velocity) > 5)" but still not working. it still applies the whole field to all particles. and all particles still drop.

republicavfx
02-23-2011, 11:22 AM
couple of things...under the field there is a tab called special effects...turn on ´per vertex´

then also use ALOT of attenuation in the field or what you will have is each particle influencing every other particle. thats not what you want... crank attenuation up to 20 or 30 or something

also...make SURE your attributes are properly named. i frequently forget if you have to use an underscore or ´.´ grammar and then the effect doesnt work and there are no big error messages...maya will just add the attribute but it wont work. i typically go to the help then copy and past the example lol

try doing a simple version without your expressions and just use ramps and see if you can get it working then once u get the hang of it switch back over to you real scene

Aikiman
02-23-2011, 06:49 PM
I think your particles need to know what happening at birth as well, so code in some creation expressions using your new _magnitude attribute.

CGTalk Moderation
02-23-2011, 06:49 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.