33 lines
778 B
C#
33 lines
778 B
C#
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<CivilCarBehaviour>().direction = 1;
|
|
car.GetComponent<CivilCarBehaviour>().civilCarSpeed = 8f;
|
|
}
|
|
}
|