Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class GameControl : MonoBehaviour {
- public GameObject lanePrefab;
- public int numberOfLanes = 20;
- // Use this for initialization
- void Start () {
- int laneNumber = 0;
- while(laneNumber < numberOfLanes)
- {
- GameObject go = (GameObject)Instantiate(lanePrefab);
- Vector3 pos = new Vector3(0, 0, laneNumber * 3);
- go.GetComponent<Transform>().position = pos;
- bool pf = Random.Range(0, 1) == 1 ? true : false;
- go.GetComponent<LaneController>().positiveFlow = pf;
- bool tr = Random.Range(0, 5) == 1 ? false : true;
- go.GetComponent<LaneController>().traffic= tr;
- float dens = Random.Range(0.001f, 0.02f);
- go.GetComponent<LaneController>().density = dens;
- float spd = Random.Range(1.0f, 20.0f);
- go.GetComponent<LaneController>().speed = spd;
- laneNumber = laneNumber + 1;
- }
- }
- // Update is called once per frame
- void Update () {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement