// Update is called once per frame void Update() { if (coinsOnMap == 0) { TimeAttack script = (TimeAttack)gameObject.GetComponent(typeof(TimeAttack)); script.Finish(); } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { GameObject bullet = Instantiate(prefab) as GameObject; bullet.transform.position = transform.position + Camera.main.transform.forward * 2; Rigidbody rb = bullet.GetComponent <Rigidbody>(); rb.velocity = Camera.main.transform.forward * 40; Destroy(bullet, 5); } if (enemyOnMap == 0) { TimeAttack script = (TimeAttack)gameObject.GetComponent(typeof(TimeAttack)); script.Finish(); } }