View Full Version : Random image on sprite

03 March 2008, 10:45 PM
So I'm trying to generate some leaves with particles. It seems that my sprites are refferencing my image sequence fine, but they're randomly selecting one frame for the whole particle system, rather than per a partcle.

I have an expression on my particle system that reads:
particleShape1.spriteNumPP=trunc (rand (0, 4));

I thought that should take a random frame from the image sequence (image sequence is five frames), but it's sampleing for the whole thing. The expressionI have on the image sequence was either =frame%5 or =rand(1,5), but that seems to keep changing the image for the whole thing as time moves on.

So How do I get it where I can play an animation but my particles are all stuck to one image, thats random per a particle? I feel like I'm missing a step, but I've never done this for anything other than animation. I've never tried to get it to actually not play animation.

03 March 2008, 08:54 AM
I'd use the following workflow:

1) load the first image for the sprites material, check image sequence, delete the expression that maya automatically creates, go to frame 1 write down 1 in Image Number and set a key, go to frame 5, write down 5 (assuming that you have 5 images) in Image Number and set a key....

2) go in Interactive Sequence Caching Options, check use interactive sequence caching, set sequence start to 1, set sequence end to 5 and leave sequence increment to 1...

3) go in to the particles shape node, add the spriteNumPP attribute and in the creation expressions tab write down : spriteNumPP = rand (1,6)....

at this point each sprite is created with a random image between 1 and 5 ( i write down 6 beacuse the rand function would reach the number 5 if I write down a range from 1 to 5)....

i hope this can be useful

CGTalk Moderation
03 March 2008, 08:54 AM
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.