// Update is called once per frame void Update() { pause = sv.getPause(); if (pause == false) { timer -= Time.deltaTime; if (timer <= 0 && !(coin.tag == "Tyre" && sv.getObstacles() == false)) { Vector2 coinPos = new Vector2(Random.Range(-6.5f, 6.9f), transform.position.y); Instantiate(coin, coinPos, transform.rotation); timer = delaytimer; } } }
// Update is called once per frame void Update() { pause = sv.getPause(); obstacles = sv.getObstacles(); if (pause == false && obstacles == true && boostMode == false) { timer -= Time.deltaTime; if (timer <= 0) { Vector3 carPos = new Vector3(Random.Range(-cameraWidth / 2 + 2.5f, cameraWidth / 2 - 2.5f), transform.position.y, 0); //get random position in the area above the camera // 2.5f keeps the randomly spawned cars off the grass carNo = (int)Random.Range(0, 4); //get random car from the prefabs Instantiate(cars[carNo], carPos, transform.rotation); //instantiate it with the random position timer = delaytimer; //reset the timer } } }