Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: boragungor on October 22, 2014, 07:50:03 AM

Title: Changing the color of an object for every frame with Playmaker[SOLVED]
Post by: boragungor on October 22, 2014, 07:50:03 AM
Hi all,

I've been trying to change a cube's color for every frame and I've accomplished this with a script named changeColor which I've come across on Unity forums (http://answers.unity3d.com/questions/314737/how-to-randomly-change-a-color-on-an-object-in-c.html (http://answers.unity3d.com/questions/314737/how-to-randomly-change-a-color-on-an-object-in-c.html))

The code follows as below:

public class ChangeColor : MonoBehaviour {

   public float timer = 0.0f;
   public float timer_set = 0.5f;
   void Start ()
   {
      
   }
   
   
   void Update ()
   {
      timer += Time.deltaTime;
      if (timer >= timer_set)//change the float value here to change how long it takes to switch.
      {
         // pick a random color
         Color newColor = new Color( Random.value, Random.value, Random.value, 1.0f );
         // apply it on current object's material
         renderer.material.color = newColor;
         timer = 0;
      }
      
      
   }



What I'm trying to accomplish is to have the same effect without this script but with Playmaker Color Interpolation or Animate Colors but for reasons I can't understand I have not been able to do it. Any help is appreciated.

Thank You
Title: Re: Changing the color of an object for every frame with Playmaker
Post by: 600 on October 22, 2014, 11:04:03 AM
Hello,

before animation use Get Material Color action,
use "Color" variable type to save a color,
then animate those variables in one state with SetMaterialColor every frame as the last action.
Title: Re: Changing the color of an object for every frame with Playmaker
Post by: boragungor on October 22, 2014, 12:55:25 PM
Thank for the reply 600 but actually I can't see Get Material Color action in the action browser, there is only Set Material Color.
Title: Re: Changing the color of an object for every frame with Playmaker
Post by: 600 on October 22, 2014, 12:59:49 PM
oh sorry I forgot that it was not with the base install,

Here:
http://hutonggames.com/playmakerforum/index.php?topic=1996.0
Title: Re: Changing the color of an object for every frame with Playmaker
Post by: boragungor on October 25, 2014, 01:15:26 PM
Thanks 600

Actually I could'nt manage to do it using fsm but rather modified the code I'd mentioned above and turned it into an action, I'm sharing it as an attachment.