PDA

View Full Version : Particle using a ramp to scale over time but with some random?


Strob
02-27-2008, 02:16 PM
Hi,

I'm trying to get my particles (sprite) to scale over time using a ramp, but I would like at the same time to have different size for each particle but each one increasing their size smoothly over time.

I tried this:

I created 2 per particles attributes
gBulShape.myRand and gBulShape.myRamp


in creation:

gBulShape.spriteScaleYPP = gBulShape.myRand * gBulShape.myRamp;
gBulShape.myRand = rand(.7,2.8);
gBulShape.spriteScaleXPP = gBulShape.spriteScaleYPP;

and I assigned a ramp to gBulShape.myRamp

in runtime after dynamics:

gBulShape.spriteScaleYPP = gBulShape.myRand * gBulShape.myRamp;
gBulShape.spriteScaleXPP = gBulShape.spriteScaleYPP;


But what I get with this is my particles poping their size over time. Since I put the rand in creation I thought it would be randomized only one time but at every frame it seems to be randomize in runtime.

What should I do to stop that?


Many thanks in advance!

DrYo
02-27-2008, 04:33 PM
Use the noise function instead of the rand function. Noise gives smooth interpolation when you attach it to time.

Strob
02-27-2008, 05:34 PM
I will try... But I don't want the noise or random to affect the particles over time. I just want a the noise to effect each particle one time so there are bigger particles and smaller ones. But the smaller particles STAY smaller for the entire course of their life.


The effect I'm trying to achieve is one of bubbles created by a diver in a swimming pool.

Strob
02-27-2008, 05:43 PM
Yes that's what I thought. The particles still cycle their size over their life. Becoming bigger shrinking and becoming bigger over again. It is maybe smoother with the noise function but still varying over time.

Is there any way to affect them only once at creation.

Strob
02-27-2008, 06:32 PM
Ok. I'm sorry for everybody who read this!

I found my mistake.

The expressions I wrote are supposed to work. I can confirm it is working written as this:

runtime after dynamics

particleShape1.spriteScaleYPP = particleShape1.myRampPP * particleShape1.myRandPP;
particleShape1.spriteScaleXPP = particleShape1.spriteScaleYPP;


creation

particleShape1.myRandPP = rand(0.1,3);
particleShape1.spriteScaleXPP =0;
particleShape1.spriteScaleYPP =0;


The problem was that I was also randomizing the lifespanPP and I was randomizing it in runtime.... I should have randomized it only in creation.

CGTalk Moderation
02-27-2008, 06:32 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.