playMaker

Author Topic: How to loop or pingpong a color/variable?  (Read 3797 times)

indeed

  • Junior Playmaker
  • **
  • Posts: 85
How to loop or pingpong a color/variable?
« 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.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: How to loop or pingpong a color/variable?
« Reply #1 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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

indeed

  • Junior Playmaker
  • **
  • Posts: 85
Re: How to loop or pingpong a color/variable?
« Reply #2 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.

indeed

  • Junior Playmaker
  • **
  • Posts: 85
Re: How to loop or pingpong a color/variable?
« Reply #3 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?