Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: indeed on February 11, 2015, 05:25:24 PM

Title: How to loop or pingpong a color/variable?
Post by: indeed on February 11, 2015, 05:25:24 PM
Hello, I have a scene in which I have about 20 spheres and I want the color on all of them to animate between black and white. I noticed that iTween had lots of nice looping functions, but can't see how to apply these to a color variable. Is the best way to do this somehow within one action, or do you need to do it with a series of States? I need to do it for many objects, so I'm just concerned about overloading the CPU.
Title: Re: How to loop or pingpong a color/variable?
Post by: Lane on February 11, 2015, 05:29:55 PM
Have you considered using a texture for this instead? Possibly a gradient and changing the offset to blend from on side to the other.
Title: Re: How to loop or pingpong a color/variable?
Post by: indeed on February 11, 2015, 05:34:29 PM
That is interesting.....though I think that would make it look as if the color was moving through the object on an axis, not that it was pulsing uniformly between black and white.
Title: Re: How to loop or pingpong a color/variable?
Post by: indeed on February 11, 2015, 10:24:14 PM
I suppose this is a question about looping values in general in Playmaker. I am used to doing something like this, say to animate an alpha:

var lerp : float = Mathf.PingPong (Time.time, duration) / duration;
 
     alpha = Mathf.Lerp(0.0, 1.0, lerp) ;
     renderer.material.color.a = alpha;

However I would prefer to do this in Playmaker using actions, if possible. Is this an unusual usage of Playmaker to do this kind of loop somehow? Is this better done in a normal script?