these are dark times at developer studio:I am making generative terrain tiles so I need to calculate the mountains on each tiles relative to their position in world space.
when I try to get the vertices world position with TransformPoint, it’s still returning their local position:
Here is the code and debuglog- sampling the 1st vertex of 100 tiles, the tiles are displaced by 200, 400,etc, and their vertex TransformPoint are all the same:
function nzprl ( meshobject : GameObject){//this function takes mesh objects and changes their vertices in XY and Z into mountains
Debug.Log( "object position " +meshobject.transform.position );
var mymeshfilter : Mesh = meshobject.GetComponent(MeshFilter).mesh;
var vtxArray : Vector3[];
var scale = 7;
if (vtxArray == null) vtxArray = mymeshfilter.vertices;
var vertices = new Vector3[vtxArray.Length];
for (var i=0;i<vertices.Length;i++)
{
if ( i== 0 ){Debug.Log( "vertex-position "+vtxArray *); }*
vtxArray = transform.TransformPoint(vtxArray*);*
_ var vertex = vtxArray*;*
if ( i== 0 ){Debug.Log( "vertex-transformpoint position "+vtxArray ); }_
vertex.y += (Mathf.PerlinNoise(vtxArray_.x,5.456)Mathf.PerlinNoise(vtxArray.z,7.53)-*
.5) * scale;_
_ vertices = transform.InverseTransformPoint(vertex);_
* }*
* mymeshfilter.vertices = vertices;*
* mymeshfilter.RecalculateNormals();*
* mymeshfilter.RecalculateBounds();*
* DestroyImmediate(meshobject.collider);*
* meshobject.AddComponent(“MeshCollider”);*
}
[7299-transform+problem.jpg|7299]