playMaker

Author Topic: Changing the color of an object for every frame with Playmaker[SOLVED]  (Read 5302 times)

boragungor

  • Playmaker Newbie
  • *
  • Posts: 17
  • Who really wrote Beethoven's music to begin with?
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)

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
« Last Edit: October 25, 2014, 01:17:26 PM by boragungor »

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 715
    • Flashing Lights
Re: Changing the color of an object for every frame with Playmaker
« Reply #1 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.

boragungor

  • Playmaker Newbie
  • *
  • Posts: 17
  • Who really wrote Beethoven's music to begin with?
Re: Changing the color of an object for every frame with Playmaker
« Reply #2 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.

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 715
    • Flashing Lights
Re: Changing the color of an object for every frame with Playmaker
« Reply #3 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

boragungor

  • Playmaker Newbie
  • *
  • Posts: 17
  • Who really wrote Beethoven's music to begin with?
Re: Changing the color of an object for every frame with Playmaker
« Reply #4 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.