I have a script in C#, when SlowMode = true it change the Time.timeScale, but Crazy mode doesn’t change the Time.timeScale
if (CrazyMode == true)
{
CrazyText.SetActive(true);
Time.timeScale = 1.5f;
}
else
{
CrazyText.SetActive(false);
Time.timeScale = 1.0f;
}
if (SlowMode == true)
{
CrazySlow.SetActive(true);
Time.timeScale = 0.5f;
}
sorry for my english, but is not my primary language.
Edit: This is all the script
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class SumarPuntos : MonoBehaviour {
public GameObject Player;
static double puntuacion;
public Text Texto;
public GameObject Spawner;
public GameObject Replay;
public GameObject Mainmenu;
public ParticleSystem Rainbow;
public float emissionRate;
public GameObject CrazyText;
double Lives;
public Text TextoVidas;
double StarPoints;
public Text TextoStarPoints;
public AudioSource Musica;
public float TFast;
public float TSlow;
bool SlowMode;
bool CrazyMode;
public GameObject CrazySlow;
// Use this for initialization
void Start () {
puntuacion = 0;
Lives = 3;
StarPoints = 0;
TFast = 0;
TSlow = 0;
SlowMode = false;
CrazyMode = false;
}
// Update is called once per frame
void FixedUpdate()
{
if (TFast < 0)
{
TFast = 0;
CrazyMode = false;
}
if (TFast > 0)
{
CrazyMode = true;
}
if (TSlow < 0)
{
TSlow = 0;
SlowMode = false;
}
if (TSlow > 0)
{
SlowMode = true;
}
TFast -= Time.deltaTime;
TSlow -= Time.deltaTime;
emissionRate = Rainbow.emissionRate;
Musica.pitch = Time.timeScale;
Texto.text = "Score :" + puntuacion;
if (puntuacion < 0)
{
puntuacion = 0;
}
Rainbow.emissionRate = emissionRate - 10 * Time.deltaTime;
if (emissionRate >= 150)
{
Rainbow.emissionRate = 150 - 10 * Time.deltaTime;
}
TextoVidas.text = "X" + Lives;
if (Lives < 1)
{
Lose();
Lives = 0;
}
TextoStarPoints.text = "X" + StarPoints;
if (emissionRate < 0)
{
emissionRate = 0;
}
if (CrazyMode == true){
Time.timeScale = 1.5f;
CrazyText.SetActive(true);
}else{
Time.timeScale = 1.0f;
CrazyText.SetActive (false);
}
if (SlowMode == true)
{
CrazySlow.SetActive(true);
Time.timeScale = 0.5f;
}
else
{
CrazySlow.SetActive(false);
Time.timeScale = 1.0f;
}
if (CrazyMode == true && SlowMode == true)
{
CrazyMode = false;
SlowMode = false;
TFast = 0.0f;
TSlow = 0.0f;
CrazyText.SetActive(false);
CrazySlow.SetActive(false);
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "HappyStar")
{
StarPoints += 1;
puntuacion += 100;
Destroy(other.gameObject);
Rainbow.emissionRate = emissionRate + 15;
}
if (other.tag == "AngryStar")
{
puntuacion -= 100;
Destroy(other.gameObject);
Lives -= 1;
}
if (other.tag == "Pared")
{
Lose();
}
if (other.tag == "HappyStar" && CrazyMode == true)
{
puntuacion += 400;
Destroy(other.gameObject);
Rainbow.emissionRate = emissionRate + 10;
}
if (other.tag == "LiveStar")
{
Destroy(other.gameObject);
Rainbow.emissionRate = emissionRate + 25;
Lives += 1;
}
if (other.tag == "Firy")
{
Destroy(other.gameObject);
Rainbow.emissionRate = emissionRate - 30;
puntuacion -= 500;
}
if (other.tag == "FastStar")
{
TFast += 5;
Destroy(other.gameObject);
emissionRate += 10;
}
if (other.tag == "SlowStar")
{
TSlow += 2;
Destroy(other.gameObject);
emissionRate += 10;
}
}
public void Lose ()
{
Rainbow.emissionRate = 0;
Replay.SetActive(true);
Mainmenu.SetActive(true);
Texto.text = "You Lose:" + SumarPuntos.puntuacion;
Destroy(Spawner.gameObject);
Player.SetActive(false);
CrazyMode = false;
if (puntuacion > PuntuacionFinal.ScoreFinal)
{
PuntuacionFinal.ScoreFinal = puntuacion;
}
CrazyText.SetActive(false);
CrazySlow.SetActive(false);
}
}