- Home /
Changing a float number by time
Hi everyone... I have a float... named A , for example. I want to give a script that this script increase the size of A in 2 seconds. and in every second the size goes up 0.5... how can I do that?
Comment
Best Answer
Answer by Lo0NuhtiK · Jan 01, 2012 at 09:35 AM
Not sure how much you want it to increase after the initial two seconds, but we'll make it start at zero, wait two seconds, increase by 1, then after that every second it will increase by 0.5 -->
var A : float = 0 ;
function Start(){
yield WaitForSeconds(2); //wait for 2 seconds
A += 1 ; //increase A by 1
InvokeRepeating("AddToA", 1, 1) ; // wait one more second, then do function AddToA every second
}
function AddToA(){
A += 0.5 ; //add 0.5 to A ... invoked every second.
}