PDA

View Full Version : expression controlling emitter.rate


Eriand
12-09-2009, 09:37 PM
hia there!

I'm in need of some help regarding a project I'm working on atm.

I'm going to make an explosion that's connected to a fighter-craft of sorts.

The way I want to do it is simply have a float attribute connected to the fighter, and when turned on make it so that the emitter coupled to the fighter emits only 1 particle (instantly), which emits different particles etc.

As I will have LOTS of these fighters in the scene (doing various things and blowing up at different times) I really want to simplify the time it will take to animate the death of every fighter, hence just change the variable to "on" and from there on it does the whole emission thing. (I don't want to do anything through keys though, as I want to try and do it in different ways :) )

thanks for your time
/Erik

Aikiman
12-09-2009, 09:45 PM
You can create a custom attribute on your transform node so that it will show up in the channel editor. Just create a boolean so you have just "true" and "false" or 0,1.

Then create an expression node like:

if (fighter1.control == 1)
setAttr "emitter1.rate" 1;
else
setAttr "emitter1.rate" 0;

You would probably want to set the emitter rate to something like 100 and change the max count on the particle to 1. Because a rate of one is one per 24 frames so it may emit on the 23rd, whereas 100 will ensure an emission on the first frame.

Eriand
12-09-2009, 10:08 PM
Thanks!

Also, is it possible to have the one launched particle set the rate of the emitter to 0?

Thanks
/Erik

Aikiman
12-09-2009, 10:37 PM
Probably change your expression to this for starters...

if (frame ==1)
setAttr "fighter1.control" 0;

if (fighter1.control==1)
setAttr "emitter1.rate" 500;
else
setAttr "emitter1.rate" 0;

so everytime you rewind your scene it flushes your control attribute back to zero.
Then in runtime on your particle you can write something like:

if(particleShape1.particleId > 0)
setAttr "fighter1.control" 0;

You wont be able to keyframe this control attribute otherwise your expressions wont work so the best thing to do is write another piece of small code on your original expression node like:

if(frame == 50)
setattr "fighter1.control" 1

this will activate your emitter at frame 50 for example. Now you could also create another custom float attribute on your transform node so that you can change the frame number from the channel editor rather than going into your expression editor all the time.

Something like:

if(frame == fighter1.frameNum)
setattr "fighter1.control" 1

now you can keyframe fighter1.frameNum instead from the channel editor.

Eriand
12-09-2009, 10:50 PM
Thank you man! :)

Top of the day to you!

/Erik

Eriand
12-10-2009, 07:31 PM
THanks for the help yesterday, got it to work :)

What I kind of need help with now is linking a particles age (PP) to a solid fractals Bias setting.

Tried a few different things, but couldn't get it to work. :\

Any pointers?

Thanks,
/Erik

Aikiman
12-10-2009, 08:02 PM
THanks for the help yesterday, got it to work :)

What I kind of need help with now is linking a particles age (PP) to a solid fractals Bias setting.

Tried a few different things, but couldn't get it to work. :\

Any pointers?

Thanks,
/Erik

The way I would do it is to create a User Scalar 1PP on the particleShape itself and map a ramp to it based on age. Now you have an attribute that can drive your bias, you just have to hook it up through the particle sampler node.

So lets say you have already mapped a solid fractal to your color input on the cloudy particle. Now create a particle sampler info node and connect the UserScalar1PP to the bias on your texture, bingo!

To adjust the min/max values on your bias you can change the values on the array mapper instead. The array mapper is associated with the User Scalar ramp.

Also, now that you have a ramp to control the bias, you could place in extra color chips so your bias could go up and down during its lifespan. Dont you just love Maya for its simplicity? Probably take a Houdini user twice as long to hook that up in nodes. ;)

Good luck.

CGTalk Moderation
12-10-2009, 08:02 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.