void OnMouseDown () {
if(name == “SlowButton”){
PlaneMovement.GameSpeed = 0.5f;
}
if(name == “MediumButton”){
PlaneMovement.GameSpeed = 1f;
}
if(name == “FastButton”){
PlaneMovement.GameSpeed = 2f;
}
if(name == “VeryFastButton”){
PlaneMovement.GameSpeed = 3f;
}
Application.LoadLevel(“game”);
}
I enter with this code into the Next Scene and there i have a code for some extra Power like speedup while collision occurs for that the code is:
if(C.tag == "Dimond"){
Camera.main.GetComponent<StoneInitiate>().DimondList.Remove(C.gameObject);
Destroy (C.gameObject);
Camera.main.GetComponent<StoneInitiate>().StoneCounter+=20;
smooth = 4f;
SpeedUpTimer = 5f;
SpeedUp = true;
}
speedup code is:
PlaneMovement.GameSpeed = Mathf.Lerp (PlaneMovement.GameSpeed,smooth,Time.time);
if(SpeedUp){
SpeedUpTimer -= Time.deltaTime;
print(SpeedUpTimer);
if(SpeedUpTimer <= 0){
SpeedUp = false;
smooth = PlaneMovement.GameSpeed;
}
It Works Fine when collision occurs but smooth takes value 4f and It Doesn’t get value form
PlaneMovement.GameSpeed
please help me for that I am new in Unity.
Thanks in advance.