Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started 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
-
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.
-
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.
-
oh sorry I forgot that it was not with the base install,
Here:
http://hutonggames.com/playmakerforum/index.php?topic=1996.0
-
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.