Is it possible to have the color of an object turn to green, then to the original color, then to blue then to the original color, the transition sequence being made in say 0.9 seconds and loop this whole group of transitions for a specific amount of time?
I use the following script, which is applied on the object the color of which I want to change the way I described. The color changing sequence will begin once "condition" boolean is true (condition is a static var of type boolean that's located in "OtherScript.js").
function Update () {
if (OtherScript.condition){
InvokeRepeating("ChangeColors",0,1.2);
}
}
function ChangeColors (){
iTween.ColorTo(gameObject,{"g": 2, "time": 0.3});
iTween.ColorFrom(gameObject,{"g": 2, "time": 0.3, "delay":0.3});
iTween.ColorTo(gameObject,{"b": 2,"time": 0.3, "delay":0.6});
iTween.ColorFrom(gameObject,{"b": 2,"time": 0.3, "delay":0.9});
}
I test the game with Unity Remote. At the beginning "condition" is false (default value of this var) and the fps are about 170. When it becomes true (this happens by selecting some powerups that are supposed to give my object some special characteristics for a specific amount of time) the fps fall to 2 (!) which is unplayable of course.
Thanks in advance for any suggestion! :-)