HATEBIN
>
using System.Collections; using System.Collections.Generic; using UnityEngine; public class CarSpawner : MonoBehaviour { [SerializeField] GameObject[] cars; int rand; // Start is called before the first frame update void Start() { Spawn(); } void Spawn() { for(int i=0; i < transform.childCount; i++) { rand = Random.Range(0, cars.Length); cars[rand].GetComponent
().currentTrafficRoute = this.gameObject; cars[rand].GetComponent
().currentWaypointNumber = i; Instantiate(cars[rand], transform.GetChild(i).transform.position, transform.GetChild(i).transform.rotation); } } }