Game Development Reference
In-Depth Information
FIG 7.19 A plane and FPC for starting
the project.
Step 3. Select the plane in the Hierarchy and remove its Mesh Collider
component in the Inspector. We will add a new one shortly after its
terrain heights have been modified.
Step 4. Create a JavaScript file called makeTerrain.js. Add the code
shown in Listing 7.1 .
Listing 7.1 Script to Create Random Height Values on a Mesh
function Start()
var mesh: Mesh = this.GetComponent(MeshFilter).mesh;
var vertices: Vector3[] = mesh.vertices;
for (var v = 0; v < vertices.Length; v++)
vertices[v].y = Random.Range(0,10);
mesh.vertices = vertices;
Step 5. Attach the script to the plane.
Search Nedrilad ::

Custom Search