- Home /
Question by
Krystian_ · Jun 18, 2018 at 04:07 PM ·
scripting problemprocedural generation
How to change vertices position.
I try to modify standard sphere's mesh, to make each vertex local "y" position a bit other than in the beginning to make it look a bit like spherical terrain.
I wrote this script and make this in void that is called by start method.
Sorry for my bad english.
mesh = GetComponent<MeshFilter> ().mesh;
Vector3[] vertices = mesh.vertices;
for (int i = 0; i >= vertices.Length; i++) {
float height = Random.Range (1, 5);
vertices [i] = new Vector3 (0, height, 0);
}
mesh.vertices = vertices;
Comment
Answer by Vicarian · Jun 18, 2018 at 05:51 PM
Your iterator condition in the for loop is incorrect. Use instead:
for (int i = 0; i < vertices.Length; i++) {
float height = Random.Range (1, 5);
vertices [i] = new Vector3 (0, height, 0);
}
Your answer
Follow this Question
Related Questions
I keep getting this error! 0 Answers
Can we Plant tree on Planes Instead of Terrain using Procedural Placement 0 Answers
How to remove/tag tiles left by procedural generation? 0 Answers
Help me finish my room generator 0 Answers
Help making orbiting planets,How to rotate around the objects with the largest mass? 0 Answers