Simply Iam instantiating cube and giving them translation at a specific direction based on a speed variable , when i want to increase the speed over time in type in the update
CubeSpeed += 1*Time.deltaTime;
That Suppose to increase the Speed by 1 every 1 Second but it doesn’t … the old Cubes that are instantiated are having the old Speed and the new instantiated one are even though i reduced the num to a very low number like .0001 and it still extremely fast , i tried a function and Invoke Repeat it but it doesn’t work and a very strange attitude happened when i removed it again , the cubes are instantiated normally in the beginnig and then the cubes get closer and closer although i didn’t change the time at all ,i also tried to make it change based on the time passed so i used the function that are commented below but it didn’t work either !!! + my game is endless so how am i suppose to make it endless so how am i suppose to increase it without using invokeRepeating or even the Update? i just want to speed the cube over time why the hell it doesn’t work ?? here is the very simple code i used
static var CubeSpeed:float =.5;
private var TimeNow = Time.time;
//private var CurrentSpeed=2;
private var PrevTime=0;
//
//
//
function Update () {
transform.Translate(0,0,-.1*CubeSpeed);
if(transform.position.y >=10.13507)
{
Destroy(gameObject);
GameController.Score +=10;
}
// if(TimeNow - PrevTime >=3)
// {
// //ChangeCubeSpeed (1);
// PrevTime=TimeNow;
// }
// Debug.Log(CubeSpeed);
//// // function ChangeCubeSpeed( n:float )
//{
// n= .5;
// CubeSpeed+= n;
//}
//
//
//
}