Beispiel #1
0
    void Awake()
    {
        //create walking ground
        plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
        scale = (int)gridWorldSize.x/10; // scaling the plane gives an 10*scale x 10*scale (x-axis x z-axis) plane, set to 50
        plane.transform.localScale = new Vector3 (scale, 1, scale); //scales only in x and z dimensions
        grass = Resources.Load ("Materials/TL_Grass_01/U5_Material/TL_Grass_01_U5") as Material;
        plane.GetComponent<Renderer> ().material = grass;
        plane.layer = 11;

        //set borders
        walls.Add ((GameObject) Resources.Load("Borders/Walls/wall1"));
        walls.Add ((GameObject) Resources.Load("Borders/Walls/wall2"));
        walls.Add ((GameObject) Resources.Load("Borders/Walls/wall3"));
        walls.Add ((GameObject) Resources.Load("Borders/Walls/wall4"));
        for (int i =0; i< walls.Count; i++) {
            Instantiate (walls[i], walls[i].transform.position, walls[i].transform.rotation);
        }

        //choose skybox
        skyboxes.Add ((Material) Resources.Load("Skyboxes/skybox1"));
        skyboxes.Add ((Material) Resources.Load("Skyboxes/skybox2"));
        skyboxes.Add ((Material) Resources.Load("Skyboxes/skybox3"));
        skyboxes.Add ((Material) Resources.Load("Skyboxes/skybox4"));
        skyboxes.Add ((Material) Resources.Load("Skyboxes/skybox5"));
        int randomskybox = Random.Range (0, skyboxes.Count+1);
        if (randomskybox != skyboxes.Count) {
            RenderSettings.skybox = skyboxes [randomskybox];
        }
        RenderSettings.fog = true;

        //create roads and trees
        roadbuilder = GetComponent<GenerateRoads>();
        roadbuilder.Generate ();
    }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        _generateRoads = GetComponentInParent <GenerateRoads>();
        _speed         = _generateRoads.roadSpeed;
        _mainCamera    = FindObjectOfType <Camera>();

        transform.position += Vector3.back * _speed * Time.deltaTime;
    }
Beispiel #3
0
 void Awake()
 {
     plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
     scale = 15; // scaling the plane gives an 5*scale x 5*scale (x-axis x z-axis) plane, set to 50
     plane.transform.localScale = new Vector3 (scale, 1, scale); //scales only in x and z dimensions
     roadbuilder = GetComponent<GenerateRoads>();
     roadbuilder.Generate();
 }