Basically I’m making a game where the player object (a ball) avoids some obstacles by jumping and such. When the game begins the ball accelerates to its MaxSpeed(a private var), which increases by 2 every 30 seconds, making the game a bit harder, but when the ball collides with the obstacle, the game should restart, reset the score, and reduce the MaxSpeed back to MaxSpeed1, which is the starting limit. While the first 2 things work, the last one doesn’t. Any ideas?
.
.
.
var MaxSpeed1:float=12;
private var MaxSpeed:float=MaxSpeed1;
.
.
.
if(Time.time-startTime>nextSpeedtime)
{
MaxSpeed+=2.0;
nextSpeedtime+=speedPeriod;
}
.
.
.
function OnCollisionEnter(col: Collision){
if (col.transform.name == "zid"){
MaxSpeed=MaxSpeed1;
Application.LoadLevel(Application.loadedLevel);
currentScore=0;
}
}
Note that everything works like a charm, apart from the “MaxSpeed=MaxSpeed1”
edit:I also tried doing something as simple as “MaxSpeed=12”, but it continues growing.