View Full Version : Maya expression random rotation connected to speed

12 December 2012, 09:41 PM

Im trying to create a bunch of objects that slowly fill a rectangular shape. They need to be realistically falling, and stacking onto eachother. So far ive discovered the following method to doing this:

Create my shape, create a particle emitter, added gravity, then create an instancer replacement, select the mesh, and the particle shape. Then select my rectangular shape i want to fill, select the particle and click make collide. For the particles to collide with eachothers ive added a radial field to them. Now they somewhat stack, but do not stay still at the bottom. This is a problem I will need to tackle later on. Then to make it more dynamic I want the falling shapes to be rotating, so I added an expression I found online (not good at writing expressions myself).

Added this to the per particle array attribute under creation:
float $rotRand=rand(180);

and under runtime before dynamics I added:
particleShape1.rotateMe +=5

But now the particles keep rotating even when they arent falling anymore I need to stop this. Fumbled around with some if / else statements connected to speed but couldnt get that part to work. Hopefully someone can give me a helping hand on this one because im not very familiar on this matter.

Thanks in advance!

12 December 2012, 11:03 PM
Well Id run with nParticles for a start even if they are somewhat buggy in places, just for the fact they have self collisions (spheres only), this may make your particles more stable. If you cant use nParticles then lower the conserve a little, hopefully they will settle.

In terms of rotations slowing down and stopping, try and think about what it is that correlates to the slowing down, on a very simplistic level its velocity right? So as the particles velocity gets lower we could use that as a multiplier on our rotations.

Velocity is a vector but we need a single float value as our mulitplier - take a look at the 'mag' function to achieve this. Then use that value and mulitply against your rotateMe+=5.

12 December 2012, 11:14 PM
Thanks for your quick reply! In the meantime I cintinued my search, stumbled across a tutorial using Nparticles, and found that they are indeed way more usefull. Rotation, settling works quite nicely now. I think this may very well be usefull for my final animation. The meshes I spawn even render rather quickly in large quantities with mental ray on 2xHD resolution. Everything I hoped for!

CGTalk Moderation
12 December 2012, 11:14 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.