Game Development Reference
In-Depth Information
and buildings. You will also find eight building models already
downloaded from Turbosquid on the Web site as Chapter Seven/
Step 7. Add the buildings to the Project.
Step 8. Add each building into the Scene and position them on the
plane. Because different artists created them, their scaling will be
different. Resize and rotate each building as you see fit such that they
have reasonable relative sizes and orientations.
Step 9. Create eight prefabs in the Project—one for each
building. Drag each building out of the Hierarchy and onto its
own prefab.
Step 10. Modify makeCity.js to that in Listing 7.4 .
Listing 7.4 Using Building Prefabs to Create a City Based
on Perlin Noise Height Values
var buildings: GameObject[];
function Start()
var surface : Perlin = new Perlin();
var mesh: Mesh = this.GetComponent(MeshFilter).mesh;
var vertices: Vector3[] = mesh.vertices;
var scalex = this.transform.localScale.x;
var scalez = this.transform.localScale.z;
for (var v = 0; v < vertices.Length; v++)
var perlinValue = surface.Noise (
vertices[v].x * 2 + 0.1365143,
vertices[v].z * 2 + 1.21688) * 10;
perlin Value =
Mathf. Round((Mathf.Clamp (
Vector3(vertices[v].x * scalex,
vertices[v].z * scalez),
mesh.vertices = vertices;
Search Nedrilad ::

Custom Search