Hello!
I've been trying to scale sprites up, and then after a set step size up, I want them to rest back on their intended size. I'll post the script and then explain what's not working.
int $stepSizeUp = 8;
int $stepSizeDown = 4;
float $spriteScaleMax = (nParticleShape5.radNumber + .3); \ << the radNumber is the radius determined at creation
float $spriteScaleMin = (nParticleShape5.radNumber - .2);
float $scaleUp = ($spriteScaleMax / $stepSizeUp);
float $scaleDown = ((nParticleShape5.spriteScaleXPP -$spriteScaleMin) / $stepSizeDown);
$time = `currentTime -q`;
$timeDif = ($time - nParticleShape5.creationTime); \ << the creation time just queries the time in the creation expression
if ($timeDif < $stepSizeUp) {
nParticleShape5.spriteScaleXPP += $scaleUp;
nParticleShape5.spriteScaleYPP += $scaleUp;
if (nParticleShape5.spriteScaleXPP >= $spriteScaleMax) {
nParticleShape5.spriteScaleXPP = $spriteScaleMax;
nParticleShape5.spriteScaleYPP = $spriteScaleMax;
}
}
if ($time > (nParticleShape5.creationTime + $stepSizeUp)) {
nParticleShape5.spriteScaleXPP -= $scaleDown;
nParticleShape5.spriteScaleYPP -= $scaleDown;
if (nParticleShape5.spriteScaleXPP <= $spriteScaleMin) {
nParticleShape5.spriteScaleXPP = $spriteScaleMin;
nParticleShape5.spriteScaleYPP = $spriteScaleMin;
}
}
So pretty much what's happening is that because the if statements are based off of time, things aren't calculating correctly and I'm getting strange results like instead of stopping at the specified scale, they particles continue to scale down until they hit 0. I couldn't think of another way to scale back down other than using time though, since using an if statement outside the last loop like
if (nParticleShape5.spriteScaleXPP < $spriteScaleMin)
because in the initial scale up it would immediately hop to the minimum scale. Anyway, any help would be much appreciated, this script works for the most part for what I need, but there a few areas where big problems are starting to arise.
Thanks!