// Update is called once per frame void Update() { for (int i = 0; i < 10; i++) { if (Input.GetKeyDown("" + i.ToString())) { //List<GameObject> cars = FindAllPrefabInstances(CarFinal); GameObject[] cars = GameObject.FindGameObjectsWithTag("Player"); foreach (GameObject car in cars) { car_script script = car.GetComponent <car_script>(); if (script.name == i.ToString()) { script.isActive = true; } else { script.isActive = false; } } } } }
private void Awake() { cs = GameObject.Find("scene").GetComponent <CarSpawner>(); car = transform.parent.GetComponentInParent <car_script>(); }