- Home /
Variable is not acknowledge...why???? please help
I have this script that works fine without any errors. But its not working as it should. I need the (legacy)animations to increase in speed over time. Time is taken from another script and the debug recognizes it fine, the speed updates in the inspector fine too. But the animations continue at same original speed and i cant understand why. i must be close surely. any hints please? i have spent a week trying to get this. help:)
pragma strict
var Anims = ["Roll", "Spin"];
var Model: GameObject;
var Upspeed = 1;
var Other : time;
function Update () {
Debug.Log(Other.score);
if (Other.score >= 12) {
Upspeed = 2;
}
Game();
}
function Game () {
var random:float = Random.Range(0,2);
if (random ==0){
animation.PlayQueued("Roll").speed = Upspeed;
}
if (random ==1){
animation.PlayQueued("Spin").speed = Upspeed;
}
}
Answer by HarshadK · May 26, 2014 at 11:52 AM
Try:
animation["Spin"].speed = Upspeed;
animation.PlayQueued("Spin");
thgankyou. Although this worked ok, it still didnt alter the speed over time unfortunately. Im looking into animationState, i think this might solve it, i'll repost here if i can make it work :)
How do you want to achieve this 'alter the speed over time' effect for animation? Could you elaborate?
As the timer script counts past 30 seconds for instance, i wish the random animations to double in speed. Then after the game timer reaches say 1 $$anonymous$$ute have the animations increase in speed further more. Just a game that gets harder as time goes along. the timer works fine. and the speed updates in the inspector, but the animations are not affected for some reason. $$anonymous$$y script is above.
Check this code:
if (random ==0){
animation["Roll"].speed = Upspeed;
animation["Roll"].wrap$$anonymous$$ode = Wrap$$anonymous$$ode.Once;
animation.CrossFade("Roll");
}
if (random ==1){
animation["Spin"].speed = Upspeed;
animation["Spin"].wrap$$anonymous$$ode = Wrap$$anonymous$$ode.Once;
animation.CrossFade("Spin");
}
Also change this float to int in your code from Update():
var random:float = Random.Range(0,2);
to
var random:int = Random.Range(0,2);
you know its almost there. the animation does speed up now as time goes by, thats great news. Only one thing has changed and thats the animations are randomly playing without finshing their frame cycle. Not playing all the way through before changing to another. i think its the crossFade bit. i think playQueued did the trick earlier. i will try and incorporate this into your new script. thanks for your help so far.