# How can I Get A Vertices Vector In World Space

If you know how to get each vertices position (obviously through a for loop) and modify their position by getting their coordinates in world space

I thought I figured it out…
NOPE I haven’t figured it out. All of the Vectors in the array are (1.5, 0.8, 1.5). Again, how do get a vertices Vector in world space

Run each Vector3 through this - Unity - Scripting API: Transform.TransformPoint

thanks again

That worked well. Now I’m trying to move each vertice based on perlin noise. I made another script that works wll, but instead of modifying vertices, it creates and moves cubes.
Current VertexBasedDisplacementScript

``````var seed : int = 0.0;
var roundHeightToInt : boolean;
var noiseScale : float = 6.5;
var waveHeight : int = 3;
var animateSpeed : float = 1.0;

private var mesh : Mesh;
private var vertices : Vector3[];
private var perlinHeight : float;

function Start ()
{
mesh = this.gameObject.GetComponent(MeshFilter).mesh;
}

function Update ()
{
mesh = this.gameObject.GetComponent(MeshFilter).mesh;
vertices = mesh.vertices;
for (var vert = 0; vert < vertices.Length; vert++)
{
var worldVert : Vector3 = vertices[vert];
perlinHeight = Mathf.PerlinNoise (worldVert.x,worldVert.z);
worldVert.y = perlinHeight * waveHeight;
Debug.Log (worldVert);
}
//mesh.RecalculateBounds();
//mesh.RecalculateNormals();
}
``````

CubeBasedDisplacementScript:

``````var cube : GameObject;
var colorSetsScale : boolean;
var heightSetsScale : boolean;
var animateColor : boolean;
var roundHeightToInt : boolean;
var noiseScale : float = 6.5;
var cubeHeight : int = 3;
var animateSpeed : float = 1.0;

function Start ()
{
for (var spawnPositionX = 0; spawnPositionX < cubeAmountX; spawnPositionX++)
{
for (var spawnPositionZ = 0; spawnPositionZ < cubeAmountZ; spawnPositionZ++)
{
var makeCube = Instantiate(cube, Vector3(spawnPositionX,0,spawnPositionZ), Quaternion.identity);
makeCube.transform.parent = this.transform;
}
}
for (var child : Transform in this.transform)
{
var height = Mathf.PerlinNoise(child.transform.position.x/noiseScale + (seed * 10), child.transform.position.z/noiseScale + (seed *  10));
child.renderer.material.color = Color(height,height,height,height);
if (colorSetsScale)
{
child.transform.localScale = Vector3 (height,height,height);
}
}
if (noiseScale <= 0.001)
{
noiseScale = 0.0011;
}
}

function Update ()
{
for (var child : Transform in this.transform)
{
var height = Mathf.PerlinNoise(child.transform.position.x/noiseScale, child.transform.position.z/noiseScale);
if (animateColor)
{
child.renderer.material.color = Color(height,height,height,height);
}
}
for (var child : Transform in this.transform)
{
height = Mathf.PerlinNoise(Time.time * animateSpeed + (child.transform.position.x/noiseScale) + (seed * 10), Time.time * animateSpeed + (child.transform.position.z/noiseScale) + (seed * 10));
if (!roundHeightToInt)
{
child.transform.position.y = height * cubeHeight + transform.position.y;
}
else if (roundHeightToInt)
{
child.transform.position.y = Mathf.RoundToInt(height * cubeHeight + transform.position.y);
}
if (animateColor)
{
child.renderer.material.color = Color(height,height,height,height);
}
if (colorSetsScale)
{
child.transform.localScale = Vector3 (height,height,height);
heightSetsScale = false;
}
if (heightSetsScale)
{
var cubeHeight : float = child.transform.localPosition.y;
child.transform.localScale = Vector3 (cubeHeight, cubeHeight, cubeHeight);
colorSetsScale = false;
}
}
}
``````