using System.Collections; using System.Collections.Generic; using UnityEngine; public class PoliceCarSpawner : MonoBehaviour { public float carSpawnDelay = 2f; public GameObject Police; private float spawnDealy; private void Start() { spawnDealy = carSpawnDelay; } private void Update() { spawnDealy -= Time.deltaTime; if (spawnDealy <= 0) { spawnCar(); spawnDealy = carSpawnDelay; } } void spawnCar() { GameObject car = (GameObject)Instantiate(Police, new Vector3(0, 6f, 0), Quaternion.Euler(new Vector3(0, 0, 180))); car.GetComponent().direction = 1; car.GetComponent().civilCarSpeed = 8f; } }